mapplz 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/mapplz.rb +29 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afd6d642f1ba9f4af1e97b24f03840c94dc507ce
|
4
|
+
data.tar.gz: ca8b2d24dcc24c387aeeaef5581aee867e56dddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c77b941ed3181247349d0c211b87f930839ee28bbf6f169475036a294d5b410f892286bc48b246afa7a63e31bd19153db0b105cbae31dafc33e02d80cf962dc
|
7
|
+
data.tar.gz: 98060f4edee5120b4050ce96cc425431f332f35c1fc65178e8f33b49143725994e46b6846acfa561815dc4bbfff56765600879fb6f47e9fa72b9149028e1dbe7
|
data/README.md
CHANGED
@@ -85,7 +85,8 @@ require 'mapplz'
|
|
85
85
|
|
86
86
|
@mapper = MapPLZ.new
|
87
87
|
@mapper << geo_stuff
|
88
|
-
@mapper.
|
88
|
+
@mapper.embed_html # a map embed snippet
|
89
|
+
@mapper.render_html # a full HTML page
|
89
90
|
```
|
90
91
|
|
91
92
|
This extends the Leaflet-Rails plugin. Set Leaflet defaults directly:
|
data/lib/mapplz.rb
CHANGED
@@ -105,8 +105,12 @@ class MapPLZ
|
|
105
105
|
|
106
106
|
cursor = @db_client.find(mongo_conditions)
|
107
107
|
elsif @db_type == 'postgis'
|
108
|
-
|
109
|
-
|
108
|
+
|
109
|
+
conditions = parse_sql(where_clause, add_on = nil)
|
110
|
+
conditions.each do |condition|
|
111
|
+
where_prop = condition[:field]
|
112
|
+
where_clause = where_clause.gsub(where_prop, "json_extract_path_text(properties, '#{where_prop}')")
|
113
|
+
end
|
110
114
|
|
111
115
|
cursor = @db_client.exec("SELECT id, ST_AsText(geom) AS geo, properties FROM mapplz WHERE #{where_clause}")
|
112
116
|
elsif @db_type == 'spatialite'
|
@@ -155,6 +159,28 @@ class MapPLZ
|
|
155
159
|
end
|
156
160
|
|
157
161
|
def render_html(options = {})
|
162
|
+
my_embed = embed_html(options)
|
163
|
+
```<!DOCTYPE html>
|
164
|
+
<html>
|
165
|
+
<head>
|
166
|
+
<style type="text/css">
|
167
|
+
html, body, #map {
|
168
|
+
width: 100%;
|
169
|
+
height: 100%;
|
170
|
+
margin: 0;
|
171
|
+
padding: 0;
|
172
|
+
}
|
173
|
+
</style>
|
174
|
+
<script type="text/javascript" src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
|
175
|
+
<link href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" rel="stylesheet" type="text/css"/>
|
176
|
+
</head>
|
177
|
+
<body>
|
178
|
+
#{my_embed}
|
179
|
+
</body>
|
180
|
+
</html>```
|
181
|
+
end
|
182
|
+
|
183
|
+
def embed_html(options = {})
|
158
184
|
# Leaflet options
|
159
185
|
options[:tile_layer] ||= Leaflet.tile_layer
|
160
186
|
options[:attribution] ||= Leaflet.attribution
|
@@ -344,7 +370,7 @@ class MapPLZ
|
|
344
370
|
else
|
345
371
|
# convert this with ogr2ogr and parse as a string
|
346
372
|
begin
|
347
|
-
`ogr2ogr -f "GeoJSON" tmp.geojson #{File.path(user_geo)}`
|
373
|
+
`ogr2ogr -f "GeoJSON" tmp.geojson #{File.path(user_geo)} -t_srs EPSG:4326`
|
348
374
|
user_geo = File.open('tmp.geojson').read
|
349
375
|
rescue
|
350
376
|
raise 'gdal was not installed, or format was not accepted by ogr2ogr'
|
@@ -675,11 +701,6 @@ class MapPLZ
|
|
675
701
|
count(where_clause, add_on)
|
676
702
|
end
|
677
703
|
|
678
|
-
# aliases for render_html
|
679
|
-
def embed_html(options = {})
|
680
|
-
render_html(options)
|
681
|
-
end
|
682
|
-
|
683
704
|
private
|
684
705
|
|
685
706
|
# internal error record
|