Skip to main content
deleted 55 characters in body; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Problem with matching a Matching buffer in Openlayers and the same buffer in PostGIS query

I am using a buffer tool to create a buffer on my base map in Openlayers. In addition to creating and visualizing this buffer, I pass the center point and radius to a query. The query collects all features of a certain table which fall into this buffer, and shows them on the map.

The problem is that in these two cases buffers are generated separately and are not exactly the same. This causes the query to collect less (not all) features inside the buffer. Below is an image to clarify the situation. You can see the buffer created in Openlayers in Orange color, as well as features inside it that are collected from PostGIS in black and gold colors (different features).

the circular buffer in OpenLayers and the ellipsoid shape of results retrieved from PostGIS query

Its easy to see how much difference is between these two buffers and the one that is generated by the query is more like an ellipsoid rather than circle. how

How can I solve this?

The code for generating buffer in Openlayers:

var sides = 40;
var new_geom = OpenLayers.Geometry.Polygon.createGeodesicPolygon(centroid, radius, sides, 45, projection);

and I use the following WHERE clause inside my SELECT query:

WHERE ST_DWithin(ST_Transform(h.geom, 26918), (SELECT ST_Transform(ST_GeomFromText($center_buffer, 900913), 26918)), $radius_buffer)

more information: h is the alias of my table where I want to collect features that fall inside the circular buffer. and center_buffer and radius_buffer are the variables pass by OpenLayers (the same used for creating the buffer in OpenLayers).

 

UPDATE: As As mentioned by a forum membersite user below, the city data is around hamburgHamburg and therefore I changed my SRID in my query from 26918 to 26931. With this, the problem of strange ellipsoid shape of my features inside buffer is solved but there is still a big difference between the buffer and the data retrieved from PostGIS. See image below:

enter image description here

Any further help/suggestion would be highly appreciated.

Problem with matching a buffer in Openlayers and the same buffer in PostGIS query

I am using a buffer tool to create a buffer on my base map in Openlayers. In addition to creating and visualizing this buffer, I pass the center point and radius to a query. The query collects all features of a certain table which fall into this buffer, and shows them on the map.

The problem is that in these two cases buffers are generated separately and are not exactly the same. This causes the query to collect less (not all) features inside the buffer. Below is an image to clarify the situation. You can see the buffer created in Openlayers in Orange color, as well as features inside it that are collected from PostGIS in black and gold colors (different features).

the circular buffer in OpenLayers and the ellipsoid shape of results retrieved from PostGIS query

Its easy to see how much difference is between these two buffers and the one that is generated by the query is more like an ellipsoid rather than circle. how can I solve this?

The code for generating buffer in Openlayers:

var sides = 40;
var new_geom = OpenLayers.Geometry.Polygon.createGeodesicPolygon(centroid, radius, sides, 45, projection);

and I use the following WHERE clause inside my SELECT query:

WHERE ST_DWithin(ST_Transform(h.geom, 26918), (SELECT ST_Transform(ST_GeomFromText($center_buffer, 900913), 26918)), $radius_buffer)

more information: h is the alias of my table where I want to collect features that fall inside the circular buffer. and center_buffer and radius_buffer are the variables pass by OpenLayers (the same used for creating the buffer in OpenLayers).

UPDATE: As mentioned by a forum member below, the city data is around hamburg and therefore I changed my SRID in my query from 26918 to 26931. With this, the problem of strange ellipsoid shape of my features inside buffer is solved but there is still a big difference between the buffer and the data retrieved from PostGIS. See image below:

enter image description here

Any further help/suggestion would be highly appreciated.

Matching buffer in Openlayers and same buffer in PostGIS query

I am using a buffer tool to create a buffer on my base map in Openlayers. In addition to creating and visualizing this buffer, I pass the center point and radius to a query. The query collects all features of a certain table which fall into this buffer, and shows them on the map.

The problem is that in these two cases buffers are generated separately and are not exactly the same. This causes the query to collect less (not all) features inside the buffer. Below is an image to clarify the situation. You can see the buffer created in Openlayers in Orange color, as well as features inside it that are collected from PostGIS in black and gold colors (different features).

the circular buffer in OpenLayers and the ellipsoid shape of results retrieved from PostGIS query

Its easy to see how much difference is between these two buffers and the one that is generated by the query is more like an ellipsoid rather than circle.

How can I solve this?

The code for generating buffer in Openlayers:

var sides = 40;
var new_geom = OpenLayers.Geometry.Polygon.createGeodesicPolygon(centroid, radius, sides, 45, projection);

and I use the following WHERE clause inside my SELECT query:

WHERE ST_DWithin(ST_Transform(h.geom, 26918), (SELECT ST_Transform(ST_GeomFromText($center_buffer, 900913), 26918)), $radius_buffer)

more information: h is the alias of my table where I want to collect features that fall inside the circular buffer. and center_buffer and radius_buffer are the variables pass by OpenLayers (the same used for creating the buffer in OpenLayers).

 

As mentioned by a site user below, the city data is around Hamburg and therefore I changed my SRID in my query from 26918 to 26931. With this, the problem of strange ellipsoid shape of my features inside buffer is solved but there is still a big difference between the buffer and the data retrieved from PostGIS. See image below:

enter image description here

added 13 characters in body
Source Link
Catlover
  • 449
  • 1
  • 8
  • 20

I am using a buffer tool to create a buffer on my base map in Openlayers. In addition to creating and visualizing this buffer, I pass the center point and radius to a query. The query collects all features of a certain table which fall into this buffer, and shows them on the map.

The problem is that in these two cases buffers are generated separately and are not exactly the same. This causes the query to collect less (not all) features inside the buffer. Below is an image to clarify the situation. You can see the buffer created in Openlayers in Orange color, as well as features inside it that are collected from PostGIS in black and gold colors (different features).

the circular buffer in OpenLayers and the ellipsoid shape of results retrieved from PostGIS query

Its easy to see how much difference is between these two buffers and the one that is generated by the query is more like an ellipsoid rather than circle. how can I solve this?

The code for generating buffer in Openlayers:

var sides = 40;
var new_geom = OpenLayers.Geometry.Polygon.createGeodesicPolygon(centroid, radius, sides, 45, projection);

and I use the following WHERE clause inside my SELECT query:

WHERE ST_DWithin(ST_Transform(h.geom, 26918), (SELECT ST_Transform(ST_GeomFromText($center_buffer, 900913), 26918)), $radius_buffer)

more information: h is the alias of my table where I want to collect features that fall inside the circular buffer. and center_buffer and radius_buffer are the variables pass by OpenLayers (the same used for creating the buffer in OpenLayers).

AsUPDATE: As mentioned by a forum member below, the city data is around hamburg and therefore I changed my SRID in my query from 26918 to 26931. With this, the problem of strange ellipsoid shape of my features inside buffer is solved but there is still a big difference between the buffer and the data retrieved from PostGIS. See image below:

enter image description here

Any further help/suggestion would be highly appreciated.

I am using a buffer tool to create a buffer on my base map in Openlayers. In addition to creating and visualizing this buffer, I pass the center point and radius to a query. The query collects all features of a certain table which fall into this buffer, and shows them on the map.

The problem is that in these two cases buffers are generated separately and are not exactly the same. This causes the query to collect less (not all) features inside the buffer. Below is an image to clarify the situation. You can see the buffer created in Openlayers in Orange color, as well as features inside it that are collected from PostGIS in black and gold colors (different features).

the circular buffer in OpenLayers and the ellipsoid shape of results retrieved from PostGIS query

Its easy to see how much difference is between these two buffers and the one that is generated by the query is more like an ellipsoid rather than circle. how can I solve this?

The code for generating buffer in Openlayers:

var sides = 40;
var new_geom = OpenLayers.Geometry.Polygon.createGeodesicPolygon(centroid, radius, sides, 45, projection);

and I use the following WHERE clause inside my SELECT query:

WHERE ST_DWithin(ST_Transform(h.geom, 26918), (SELECT ST_Transform(ST_GeomFromText($center_buffer, 900913), 26918)), $radius_buffer)

more information: h is the alias of my table where I want to collect features that fall inside the circular buffer. and center_buffer and radius_buffer are the variables pass by OpenLayers (the same used for creating the buffer in OpenLayers).

As mentioned by a forum member below, the city data is around hamburg and therefore I changed my SRID in my query from 26918 to 26931. With this, the problem of strange ellipsoid shape of my features inside buffer is solved but there is still a big difference between the buffer and the data retrieved from PostGIS. See image below:

enter image description here

Any further help/suggestion would be highly appreciated.

I am using a buffer tool to create a buffer on my base map in Openlayers. In addition to creating and visualizing this buffer, I pass the center point and radius to a query. The query collects all features of a certain table which fall into this buffer, and shows them on the map.

The problem is that in these two cases buffers are generated separately and are not exactly the same. This causes the query to collect less (not all) features inside the buffer. Below is an image to clarify the situation. You can see the buffer created in Openlayers in Orange color, as well as features inside it that are collected from PostGIS in black and gold colors (different features).

the circular buffer in OpenLayers and the ellipsoid shape of results retrieved from PostGIS query

Its easy to see how much difference is between these two buffers and the one that is generated by the query is more like an ellipsoid rather than circle. how can I solve this?

The code for generating buffer in Openlayers:

var sides = 40;
var new_geom = OpenLayers.Geometry.Polygon.createGeodesicPolygon(centroid, radius, sides, 45, projection);

and I use the following WHERE clause inside my SELECT query:

WHERE ST_DWithin(ST_Transform(h.geom, 26918), (SELECT ST_Transform(ST_GeomFromText($center_buffer, 900913), 26918)), $radius_buffer)

more information: h is the alias of my table where I want to collect features that fall inside the circular buffer. and center_buffer and radius_buffer are the variables pass by OpenLayers (the same used for creating the buffer in OpenLayers).

UPDATE: As mentioned by a forum member below, the city data is around hamburg and therefore I changed my SRID in my query from 26918 to 26931. With this, the problem of strange ellipsoid shape of my features inside buffer is solved but there is still a big difference between the buffer and the data retrieved from PostGIS. See image below:

enter image description here

Any further help/suggestion would be highly appreciated.

SRID in PostGIS query changed from 26918 to 26931
Source Link
Catlover
  • 449
  • 1
  • 8
  • 20

I am using a buffer tool to create a buffer on my base map in Openlayers. In addition to creating and visualizing this buffer, I pass the center point and radius to a query. The query collects all features of a certain table which fall into this buffer, and shows them on the map.

The problem is that in these two cases buffers are generated separately and are not exactly the same. This causes the query to collect less (not all) features inside the buffer. Below is an image to clarify the situation. You can see the buffer created in Openlayers in Orange color, as well as features inside it that are collected from PostGIS in black and gold colors (different features).

the circular buffer in OpenLayers and the ellipsoid shape of results retrieved from PostGIS query

Its easy to see how much difference is between these two buffers and the one that is generated by the query is more like an ellipsoid rather than circle. how can I solve this?

The code for generating buffer in Openlayers:

var sides = 40;
var new_geom = OpenLayers.Geometry.Polygon.createGeodesicPolygon(centroid, radius, sides, 45, projection);

and I use the following WHERE clause inside my SELECT query:

WHERE ST_DWithin(ST_Transform(h.geom, 26918), (SELECT ST_Transform(ST_GeomFromText($center_buffer, 900913), 26918)), $radius_buffer)

more information: h is the alias of my table where I want to collect features that fall inside the circular buffer. and center_buffer and radius_buffer are the variables pass by OpenLayers (the same used for creating the buffer in OpenLayers).

As mentioned by a forum member below, the city data is around hamburg and therefore I changed my SRID in my query from 26918 to 26931. With this, the problem of strange ellipsoid shape of my features inside buffer is solved but there is still a big difference between the buffer and the data retrieved from PostGIS. See image below:

enter image description here

Any further help/suggestion would be highly appreciated.

I am using a buffer tool to create a buffer on my base map in Openlayers. In addition to creating and visualizing this buffer, I pass the center point and radius to a query. The query collects all features of a certain table which fall into this buffer, and shows them on the map.

The problem is that in these two cases buffers are generated separately and are not exactly the same. This causes the query to collect less (not all) features inside the buffer. Below is an image to clarify the situation. You can see the buffer created in Openlayers in Orange color, as well as features inside it that are collected from PostGIS in black and gold colors (different features).

the circular buffer in OpenLayers and the ellipsoid shape of results retrieved from PostGIS query

Its easy to see how much difference is between these two buffers and the one that is generated by the query is more like an ellipsoid rather than circle. how can I solve this?

The code for generating buffer in Openlayers:

var sides = 40;
var new_geom = OpenLayers.Geometry.Polygon.createGeodesicPolygon(centroid, radius, sides, 45, projection);

and I use the following WHERE clause inside my SELECT query:

WHERE ST_DWithin(ST_Transform(h.geom, 26918), (SELECT ST_Transform(ST_GeomFromText($center_buffer, 900913), 26918)), $radius_buffer)

more information: h is the alias of my table where I want to collect features that fall inside the circular buffer. and center_buffer and radius_buffer are the variables pass by OpenLayers (the same used for creating the buffer in OpenLayers).

Any help/suggestion would be highly appreciated.

I am using a buffer tool to create a buffer on my base map in Openlayers. In addition to creating and visualizing this buffer, I pass the center point and radius to a query. The query collects all features of a certain table which fall into this buffer, and shows them on the map.

The problem is that in these two cases buffers are generated separately and are not exactly the same. This causes the query to collect less (not all) features inside the buffer. Below is an image to clarify the situation. You can see the buffer created in Openlayers in Orange color, as well as features inside it that are collected from PostGIS in black and gold colors (different features).

the circular buffer in OpenLayers and the ellipsoid shape of results retrieved from PostGIS query

Its easy to see how much difference is between these two buffers and the one that is generated by the query is more like an ellipsoid rather than circle. how can I solve this?

The code for generating buffer in Openlayers:

var sides = 40;
var new_geom = OpenLayers.Geometry.Polygon.createGeodesicPolygon(centroid, radius, sides, 45, projection);

and I use the following WHERE clause inside my SELECT query:

WHERE ST_DWithin(ST_Transform(h.geom, 26918), (SELECT ST_Transform(ST_GeomFromText($center_buffer, 900913), 26918)), $radius_buffer)

more information: h is the alias of my table where I want to collect features that fall inside the circular buffer. and center_buffer and radius_buffer are the variables pass by OpenLayers (the same used for creating the buffer in OpenLayers).

As mentioned by a forum member below, the city data is around hamburg and therefore I changed my SRID in my query from 26918 to 26931. With this, the problem of strange ellipsoid shape of my features inside buffer is solved but there is still a big difference between the buffer and the data retrieved from PostGIS. See image below:

enter image description here

Any further help/suggestion would be highly appreciated.

Source Link
Catlover
  • 449
  • 1
  • 8
  • 20
Loading