Monday, 1 February 2016

openlayers 2 - Using circle as polygon for querying PostGIS



I'm trying to query PostGIS and find some object features that intersect with a circular buffer created by the user using OpenLayers, JavaScript and PHP.


I use the following code for creating the circle:


var circle = OpenLayers.Geometry.Polygon.createRegularPolygon(
new OpenLayers.Geometry.Point(X, Y),
1,
30

);

and then I'm planning to use the following SELECT Query in my php code:


SELECT b.geom
FROM buildings AS b
WHERE ST_WITHIN (b.geom, ST_MAKEPOLYGON(circle, srid));

Q1: how can I pass the geometry created for the circle from my .JS file to .php file? can I pass it as an object? can I do something like below??:


http://mydomain.com/page.php?buffer=circle


Q2: Is my SELECT query correct? Am I using the correct function ST_MAKEPOLYGON?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...