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

GDAL export container #349

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions exporter/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
BUNDLE_PATH: "vendor/bundle"
BUNDLE_DISABLE_SHARED_GEMS: "true"
15 changes: 15 additions & 0 deletions exporter/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Debian base
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

# 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

24 changes: 24 additions & 0 deletions exporter/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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.

# [START gae_flex_quickstart_dependencies]
source "https://rubygems.org"

gem "sinatra"
# [END gae_flex_quickstart_dependencies]

group :test do
gem "rspec"
gem "rack-test"
end
34 changes: 34 additions & 0 deletions exporter/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2015 Google, Inc
# Copyright 2019 Public Lab
#
# 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 "sinatra"
require "json"

get "/" do
markdown :landing
end


post '/export' do
unless params[:metadata] &&
(tmpfile = params[:metadata][:tempfile]) &&
(name = params[:metadata][:filename])
@error = "No file selected"
return markdown :landing
end
STDERR.puts "Uploading file, original name #{name.inspect}"
@data = JSON.parse(tmpfile.read)
String @data[0]['image_file_name']
end
31 changes: 31 additions & 0 deletions exporter/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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.

# [START gae_flex_quickstart_yaml]
runtime: ruby
env: flex
entrypoint: bundle exec ruby app.rb

# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/ruby/configuring-your-app-with-app-yaml
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10

# [END gae_flex_quickstart_yaml]
30 changes: 30 additions & 0 deletions exporter/spec/hello_world_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 "Hello World" do
include Rack::Test::Methods

def app
Sinatra::Application
end

it "displays hello world text" do
get "/"
expect(last_response.body).to eq("Hello world!")
end
end
27 changes: 27 additions & 0 deletions exporter/views/landing.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Mapknitter Exporter

Welcome to the Mapknitter export API!

Please provide a json file such as <a href="https://mapknitter.org/maps/irish-uk-border-mapping/warpables.json">this</a>.

You can create it online with <a href="https://mapknitter.org/">Mapknitter</a>!

<form action="/export" method="POST" enctype='multipart/form-data'>
<input name="metadata" type="file" label="Post a json file" />
<input type="submit" value="Send" />
</form>


<style>
html {
background-color: #e5e520;
}
body {
margin: auto;
border-left: 5px solid brown;
width: 80%;
font-family: Sans;
background-color: lightYellow;
padding: 2em;
}
</style>