Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Integration of modularized export code" #1

Merged
merged 15 commits into from
Apr 12, 2019
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sudo: required
services:
- docker

install:
docker build . -t mapknitter-exporter:latest

script:
docker run mapknitter-exporter bundle exec rspec
17 changes: 8 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ FROM debian:buster
MAINTAINER Sebastian Silva <sebastian@fuentelibre.org>

# Install the application.
RUN apt-get update -qq && apt-get install -y gdal-bin ruby imagemagick ruby-sinatra ruby-kramdown

# Externally accessible data is by default put in /data
# WORKDIR /data
# VOLUME ["/data"]

# Output version and capabilities by default.
# CMD gdalinfo --version && gdalinfo --formats && ogrinfo --formats
RUN apt-get update -qq && apt-get install -y gdal-bin ruby imagemagick ruby-sinatra ruby-kramdown bundler git

# Install production dependencies.
ADD . /app
WORKDIR /app
ENV BUNDLE_FROZEN=true
RUN bundle install

# Copy local code to the container image.


CMD ruby app.rb -o 0.0.0.0 -p 80
CMD bundle exec ruby app.rb -o 0.0.0.0 -p $PORT
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
source "https://rubygems.org"

gem "sinatra"
gem "mapknitter-exporter", git: 'https://github.com/publiclab/mapknitter-exporter', branch: 'add_cartagen', glob: '*.gemspec'
# [END gae_flex_quickstart_dependencies]

group :test do
Expand Down
45 changes: 27 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
GIT
remote: https://github.com/publiclab/mapknitter-exporter
revision: 480cc2bca5a23454967caed2221a2e44a1ac309d
branch: add_cartagen
glob: *.gemspec
specs:
mapknitter-exporter (0.0.1)

GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.3)
mustermann (1.0.2)
rack (2.0.6)
rack-protection (2.0.3)
mustermann (1.0.3)
rack (2.0.7)
rack-protection (2.0.5)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
sinatra (2.0.3)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
sinatra (2.0.5)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.3)
rack-protection (= 2.0.5)
tilt (~> 2.0)
tilt (2.0.8)
tilt (2.0.9)

PLATFORMS
ruby

DEPENDENCIES
mapknitter-exporter!
rack-test
rspec
sinatra

BUNDLED WITH
1.16.2
1.13.6
39 changes: 39 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require "mapknitterExporter"
require "sinatra"
require "json"

Expand All @@ -31,4 +32,42 @@
STDERR.puts "Uploading file, original name #{name.inspect}"
@data = JSON.parse(tmpfile.read)
String @data[0]['image_file_name']

export = Export.new

# each image will be:
# {
# "cm_per_pixel":4.99408,
# "id":306187, // some unique id
# "nodes":[
# {"id":2593754,"lat":"-37.7664063648","lon":"144.9828654528"},
# {"id":2593755,"lat":"-37.7650239004","lon":"144.9831980467"},
# {"id":2593756,"lat":"-37.7652020107","lon":"144.9844533205"},
# {"id":2593757,"lat":"-37.7665844718","lon":"144.9841207266"}
# ],
# "src":"https://s3.amazonaws.com/grassrootsmapping/warpables/306187/DJI_1207.JPG",
# }

# simplified this because of https://github.com/publiclab/mapknitteexporter/pull/6... it won't work yet though
MapKnitterExporter.run_export(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the one whose parameters will change. But can we peg to the current version of mapknitter-exporter for now, and then when we change the params, we'll issue a breaking change version bump and then make the change here too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I am linking to the current (git) version of mapknitter-exporter except to the add_cartagen branch because otherwise it wouldn't require. Please merge the add_cartagen branch if it is correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, cool, could you open a PR for this? Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@data[0]['id'],
@data[0]['height'],
export,
@data[0]['map_id'],
@data[0]['images'], # TODO: these images need a special format like https://github.com/publiclab/mapknitter-exporter/blob/bf375b6f2cb09070503f523d24ba803936144875/test/exporter_test.rb#L15-L39
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we resolve this comment and rely on their formatting coming properly from the incoming JSON request?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! We need an instance of a properly format JSON request.

''
)
end


class Export

attr_accessor :status, :tms, :geotiff, :zip, :jpg # these will be updated with i.e. export.tms = "/path"

def save
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here, we should be updating a .json file stored in google cloud - but can we merge now, and add this on in a later PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please.

# need to save status.json file with above properties as strings
puts "saved"
return true
end

end
30 changes: 30 additions & 0 deletions spec/landing_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2015 Google, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative "../app.rb"
require "rspec"
require "rack/test"

describe "Mapknitter Exporter" do
include Rack::Test::Methods

def app
Sinatra::Application
end

it "displays Mapknitter Exporter text" do
get "/"
expect(last_response.body).to match("Mapknitter Exporter")
end
end