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)

"backported" from master branch
  • Loading branch information
szekerest authored and tbonfort committed Aug 14, 2012
1 parent 674fd84 commit c9821b7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
12 changes: 12 additions & 0 deletions HISTORY.TXT
Expand Up @@ -11,7 +11,19 @@ the top of the list.)

For a complete change history, please see the Git log comments.

<<<<<<< HEAD
Version 6.2.0-beta1 (2012-06-29):
=======
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):
>>>>>>> 98f50f9... Fixed the OGR driver to use point or line spatial filter geometries in degenerated cases (#4420)
-------------------------------------------------

- Fix WFS filter is produced as non-standard XML (#4171)
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

0 comments on commit c9821b7

Please sign in to comment.