Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add an overview map showing a limited number of features that need as…

…sessing.
  • Loading branch information...
commit 88baa18fd52f9fc0ceacf104023381f2995997c7 1 parent 4107ab3
@gravitystorm authored
View
19 app/controllers/projects_controller.rb
@@ -70,9 +70,28 @@ def all_snippets
@crossdomain_url = root_url + "crossdomain.xml"
end
+ def map
+ if params[:bbox]
+ bbox = bbox_from_string(params[:bbox], ProjectWay.rgeo_factory)
+ ways = @project.ways.status_unchanged.intersects(bbox.to_geometry).limit(100)
+ nodes = @project.nodes.status_unchanged.intersects(bbox.to_geometry).limit(100)
+ else
+ ways = @project.ways.status_unchanged.limit(100)
+ nodes = @project.nodes.status_unchanged.limit(100)
+ end
+ entities = [nodes, ways].flatten
+ factory = RGeo::GeoJSON::EntityFactory.new
+ collection = factory.feature_collection(entities.map { | entity | entity_feature(entity) })
+ @geojson = RGeo::GeoJSON.encode(collection).to_json
+ end
+
private
def load_project
@project = Project.find(params[:id])
end
+
+ def entity_feature(e)
+ e.loc_feature({url: view_context.url_for(e)})
+ end
end
View
17 app/views/projects/map.html.haml
@@ -0,0 +1,17 @@
+%h1= t ".unprocessed_entities"
+
+#map
+:javascript
+ var map = new OpenLayers.Map('map', {projection : new OpenLayers.Projection("EPSG:900913"),displayProjection : new OpenLayers.Projection("EPSG:4326")});
+ map.addLayer(new OpenLayers.Layer.OSM("OpenStreetMap"));
+ map.addLayer(new OpenLayers.Layer.OSM("OpenCycleMap", ["http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
+ "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
+ "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"]));
+ map.addControl(new OpenLayers.Control.LayerSwitcher());
+ map.addControl(new OpenLayers.Control.MousePosition());
+ vectors = new OpenLayers.Layer.Vector("Vectors", {projection : new OpenLayers.Projection("EPSG:4326"), styleMap : MapStyle.displayStyle()});
+ var format = new OpenLayers.Format.GeoJSON({internalProjection : new OpenLayers.Projection("EPSG:900913"),externalProjection : new OpenLayers.Projection("EPSG:4326")});
+ var format_plain = new OpenLayers.Format.GeoJSON();
+ vectors.addFeatures(format.read(#{@geojson}));
+ map.addLayer(vectors);
+ map.zoomToExtent(vectors.getDataExtent());
View
2  config/authorization_rules.rb
@@ -8,7 +8,7 @@
has_permission_on :devise_sessions, :devise_registrations, :devise_confirmations,
:devise_invitations, :devise_passwords, :to => :manage
has_permission_on :site, :to => :index
- has_permission_on :projects, :to => [:view, :all_snippets, :tagged_nodes, :tagged_ways, :tagged_relations]
+ has_permission_on :projects, :to => [:view, :all_snippets, :tagged_nodes, :tagged_ways, :tagged_relations, :map]
has_permission_on :api_maps, :to => :view
has_permission_on :api_node, :to => [:view, :status]
has_permission_on :api_way, :to => [:view, :status]
View
1  config/routes.rb
@@ -7,6 +7,7 @@
get 'tagged_nodes', :on => :member
get 'tagged_ways', :on => :member
get 'tagged_relations', :on => :member
+ get 'map', :on => :member
resources :nodes
resources :ways
resources :relations
View
14 lib/entity.rb
@@ -20,6 +20,10 @@ def status_changed
where("status is not null and status != ?", default_status)
end
+ def status_unchanged
+ where("status is null or status = ?", default_status)
+ end
+
def percentage_status_changed
if self.count > 0 && self.with_tags.count > 0
((self.with_tags.status_changed.count.to_f / self.with_tags.count) * 100).to_i
@@ -41,4 +45,12 @@ def ordered_tags
def feature_geojson
RGeo::GeoJSON.encode(geom).to_json
end
-end
+
+ def loc_feature(properties = nil)
+ if properties
+ RGeo::GeoJSON::Feature.new(self.geom, self.id, properties)
+ else
+ RGeo::GeoJSON::Feature.new(self.geom)
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.