[gdal-dev] forceToPoly causes crash when converting geom to json

Ari Jolma ari.jolma at gmail.com
Mon Nov 2 22:58:23 PST 2015


No problems at least on the other side of bindings:

my $g = Geo::OGR::Geometry->new(
     WKT=>'MULTIPOLYGON(((1 1,5 1,5 5,1 5,1 1),(2 2, 3 2, 3 3, 2 3,2 
2)),((3 3,6 2,6 4,3 3)))');
my $h = $g->ForceToPolygon;

say $h->AsText;
say $h->As(Format=>'GeoJSON');

output:

POLYGON ((1 1,5 1,5 5,1 5,1 1),(2 2,3 2,3 3,2 3,2 2),(3 3,6 2,6 4,3 3))
{ "type": "Polygon", "coordinates": [ [ [ 1.0, 1.0 ], [ 5.0, 1.0 ], [ 
5.0, 5.0 ], [ 1.0, 5.0 ], [ 1.0, 1.0 ] ], [ [ 2.0, 2.0 ], [ 3.0, 2.0 ], 
[ 3.0, 3.0 ], [ 2.0, 3.0 ], [ 2.0, 2.0 ] ], [ [ 3.0, 3.0 ], [ 6.0, 2.0 
], [ 6.0, 4.0 ], [ 3.0, 3.0 ] ] ] }

Ari

On 02.11.2015 17:13, Gane R wrote:
> I am reading a file geodb and trying to convert multipolygon to Polygon
> OGRGeometry *pGeom = NULL;
>                             OGRGeometry *pForced = NULL;
>                             pGeom = pOGRFeature->StealGeometry();
>                             if(pGeom != NULL)
>                             {
>                                 pForced = 
> OGRGeometryFactory::forceToPolygon(pGeom);
>                                 if(pForced != NULL)
>                                 {
> pOGRFeature->SetGeometryDirectly(pForced);
>                                 }
>                             }
>
> char *pJsonString = pSrcGeom->exportToJson(); //Causes crash ...
>
> Do any experience these ?
> Gane
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20151103/3fde5215/attachment.html>


More information about the gdal-dev mailing list