Limit coordinates where a tree can be added

15 views
Skip to first unread message

Angelo Trivisonno

unread,
Nov 11, 2016, 5:41:51 PM11/11/16
to opentreemap-user
I'm running an instance of OTM for a Cleveland, Ohio neighborhood, and one situation I'd like to prevent is a user adding a tree to the map in an entirely different state or region.  Is there a way for OTM to reject tree adds outside of a pre-defined boundary?

Justin Walgran

unread,
Nov 14, 2016, 12:01:42 PM11/14/16
to opentree...@googlegroups.com
If you are using OTM2 (https://github.com/OpenTreeMap/otm-core) there is built in support for restricting the area in which a tree can be added. There is currently no UI for updating the bounds, so changing it will require running a Postgres/PostGIS query.

Every row in the treemap_instance table has a bounds_id. NOTE for these examples, I am using an instance with a url_name of “test”. You would replace this with whatever the url_name of your instance is.

SELECT id, url_name, bounds_id
FROM treemap_instance
WHERE url_name = 'test';

 id | url_name | bounds_id
----+----------+-----------
 47 | test     |        30

This bounds_id value is used to join the treemap_instance table to the treemap_instancebounds table, in which the boundary geometry is stored

SELECT i.id, i.url_name, ST_AsGeoJSON(geom) as bounds
FROM treemap_instance i
JOIN treemap_instancebounds ib
ON i.bounds_id = ib.id
WHERE url_name = 'test';

 id | url_name |                                      bounds
----+----------+----------------------------------------------------------------------------------
 47 | test     | {"type":"MultiPolygon","coordinates":[...web mercator (3857) coordinate list...]}


If you do not already have a new boundary polygon, you can draw one on http://geojson.io and copy just the geometry object shown in the right sidebar



You can then remove the newline characters from that GeoJSON and use it to update the treemap_instancebounds row for your instance.

UPDATE treemap_instancebounds ib
SET geom = ST_Transform(ST_Multi(ST_SetSRID(ST_GeomFromGeoJSON('...GeoJSON...'), 4326)), 3857)
FROM treemap_instance i
WHERE i.bounds_id = ib.id
AND i.url_name = ‘test';

UPDATE 1


On Fri, Nov 11, 2016 at 3:41 PM, Angelo Trivisonno <angelo.t...@gmail.com> wrote:
I'm running an instance of OTM for a Cleveland, Ohio neighborhood, and one situation I'd like to prevent is a user adding a tree to the map in an entirely different state or region.  Is there a way for OTM to reject tree adds outside of a pre-defined boundary?

--
You received this message because you are subscribed to the Google Groups "opentreemap-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opentreemap-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages