Skip to content

Commit

Permalink
Fixed the OGR driver to use point or line spatial filter geometries i…
Browse files Browse the repository at this point in the history
…n degenerated cases (#4420)
  • Loading branch information
szekerest committed Aug 14, 2012
1 parent 05c48a3 commit 98f50f9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
2 changes: 2 additions & 0 deletions HISTORY.TXT
Expand Up @@ -16,6 +16,8 @@ Current Version (git master, 6.3-dev, future 6.4):

- Add notable changes here. Less important changes should go only in the
commit message and not appear here.

- Fixed the OGR driver to use point or line spatial filter geometries in degenerated cases (#4420)

Version 6.2 (beta1: 20120629):
-------------------------------------------------
Expand Down
44 changes: 34 additions & 10 deletions mapogr.cpp
Expand Up @@ -1225,20 +1225,44 @@ static int msOGRFileWhichShapes(layerObj *layer, rectObj rect,
* ------------------------------------------------------------------ */
ACQUIRE_OGR_LOCK;

OGRGeometryH hSpatialFilterPolygon = OGR_G_CreateGeometry( wkbPolygon );
OGRGeometryH hRing = OGR_G_CreateGeometry( wkbLinearRing );
if (rect.minx == rect.maxx && rect.miny == rect.maxy)
{
OGRGeometryH hSpatialFilterPoint = OGR_G_CreateGeometry( wkbPoint );

OGR_G_AddPoint_2D( hRing, rect.minx, rect.miny);
OGR_G_AddPoint_2D( hRing, rect.maxx, rect.miny);
OGR_G_AddPoint_2D( hRing, rect.maxx, rect.maxy);
OGR_G_AddPoint_2D( hRing, rect.minx, rect.maxy);
OGR_G_AddPoint_2D( hRing, rect.minx, rect.miny);
OGR_G_SetPoint_2D( hSpatialFilterPoint, 0, rect.minx, rect.miny );

OGR_L_SetSpatialFilter( psInfo->hLayer, hSpatialFilterPoint );

OGR_G_AddGeometryDirectly( hSpatialFilterPolygon, hRing );
OGR_G_DestroyGeometry( hSpatialFilterPoint );
}
else if (rect.minx == rect.maxx || rect.miny == rect.maxy)
{
OGRGeometryH hSpatialFilterLine = OGR_G_CreateGeometry( wkbLineString );

OGR_G_AddPoint_2D( hSpatialFilterLine, rect.minx, rect.miny );
OGR_G_AddPoint_2D( hSpatialFilterLine, rect.maxx, rect.maxy );

OGR_L_SetSpatialFilter( psInfo->hLayer, hSpatialFilterLine );

OGR_L_SetSpatialFilter( psInfo->hLayer, hSpatialFilterPolygon );
OGR_G_DestroyGeometry( hSpatialFilterLine );
}
else
{
OGRGeometryH hSpatialFilterPolygon = OGR_G_CreateGeometry( wkbPolygon );
OGRGeometryH hRing = OGR_G_CreateGeometry( wkbLinearRing );

OGR_G_DestroyGeometry( hSpatialFilterPolygon );
OGR_G_AddPoint_2D( hRing, rect.minx, rect.miny);
OGR_G_AddPoint_2D( hRing, rect.maxx, rect.miny);
OGR_G_AddPoint_2D( hRing, rect.maxx, rect.maxy);
OGR_G_AddPoint_2D( hRing, rect.minx, rect.maxy);
OGR_G_AddPoint_2D( hRing, rect.minx, rect.miny);

OGR_G_AddGeometryDirectly( hSpatialFilterPolygon, hRing );

OGR_L_SetSpatialFilter( psInfo->hLayer, hSpatialFilterPolygon );

OGR_G_DestroyGeometry( hSpatialFilterPolygon );
}

psInfo->rect = rect;

Expand Down

3 comments on commit 98f50f9

@tbonfort
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szekerest please push your changes to the 6-2 branch only. As you have done here, this fix would only end up in 6.4 (which isn't what you intended I believe). c.f.: https://github.com/mapserver/mapserver/wiki/MapServer-6.2-Release-Plan -> Git Tags/Branches

@szekerest
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How the commits are getting propagated between the branches? Do we have a policy?

@tbonfort
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm taking care of it for now, but it does not need to happen everytime something is pushed to 6-2. http://osgeo-org.1560.n6.nabble.com/motion-enter-6-2-release-cycle-td4983613.html#a4984874

Please sign in to comment.