mapplz 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/lib/mapplz.rb +29 -8
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdb69f8e5c03f22e095ea30478a819e0b860f775
4
- data.tar.gz: 1f4cc3ca096e064bdc2ebdfb222e7f6ebc6506a6
3
+ metadata.gz: afd6d642f1ba9f4af1e97b24f03840c94dc507ce
4
+ data.tar.gz: ca8b2d24dcc24c387aeeaef5581aee867e56dddb
5
5
  SHA512:
6
- metadata.gz: f4d42364d8607b621d9f10b84e7be5423f4e05bed6518392c81cdb8d702614161d17de2bd7939ab62fc77b5b6566c6f8330d44248bb86cc99d0aff0183a7bbc7
7
- data.tar.gz: 8adc7c4890f5c37571c7efe07f7400a650049d8e08debc94f7589e6544fccc14b9eed32120fc9d7646069b830b1d48b40e67914d7f63e4983be4648002429e71
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.render_html
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
- where_prop = where_clause.strip.split(' ')[0]
109
- where_clause = where_clause.gsub(where_prop, "json_extract_path_text(properties, '#{where_prop}')")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mapplz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Doiron