[gdal-dev] Esri JSON Curves
Jim Klassen
klassen.js at gmail.com
Mon Jul 2 11:40:07 PDT 2018
On Mon, Jun 25, 2018 at 4:14 PM, Even Rouault
<even.rouault at spatialys.com <mailto:even.rouault at spatialys.com>> wrote:
> > If my memories are right, you only need to set it for write
support. So
> > shouldn't be needed there.
>
> All I know is that without it set, the curved geometries were
linearized
> somewhere in OGR before they were passed to the PostGIS driver.
You should double check and spot where this comes from.
You can set a breakpoint on OGRGeometryFactory::curveToLineString
which should
be taken when linearization occurs.
As an experience, I've disabled OLCCurveGeometries and
ODsCCurveGeometries
capability declaration in the CSV driver, and no linearization
occurs when
converting to PostGIS
I've narrowed it down some more... it looks like OLCCurveGeometries is
necessary for the geometry type to be passed correctly to PostGIS.
ODsCCurveGeometries doesn't seem to matter.
Command:
gdb --args ${OGR2OGR} \
-overwrite \
Pg: \
"${SRC_URL}" \
-nln temp.parcels_test \
-nlt PROMOTE_TO_MULTI \
ESRIJSON
break OGRGeometryFactory::curveToLineString
run
With OLCCurveGeometries and ODsCCurveGeometries false, I get the following:
Warning 1: Geometry to be inserted is of type Multi Polygon, whereas the
layer geometry type is Multi Surface.
Insertion is likely to fail
ERROR 1: COPY statement failed.
ERROR: Geometry type (MultiPolygon) does not match column type
(MultiSurface)
CONTEXT: COPY parcels_test, line 1, column wkb_geometry:
"010600002032BF0D000100000001030000000100000007000000803E1A3ACD582241005A55E36CF00A4100DF0D0B13582241..."
With OLCCurveGeometries false and ODsCCurveGeometries true:
Warning 1: Geometry to be inserted is of type Multi Polygon, whereas the
layer geometry type is Multi Surface.
Insertion is likely to fail
ERROR 1: COPY statement failed.
ERROR: Geometry type (MultiPolygon) does not match column type
(MultiSurface)
CONTEXT: COPY parcels_test, line 1, column wkb_geometry:
"010600002032BF0D000100000001030000000100000007000000803E1A3ACD582241005A55E36CF00A4100DF0D0B13582241..."
With OLCCurveGeometries true and ODsCCurveGeometries false:
No Warning.
Works as expected.
With OLCCurveGeometries true and ODsCCurveGeometries true:
No Warning.
Works as expected.
In the first two cases (without OLCCurveGeometries set) I see
curveToLineString is being called when there are curves in the data, but
not on every result page (again curves are relatively rare in the dataset).
(gdb) bt
#0 0x00007ffff6f66f50 in OGRGeometryFactory::curveToLineString(double,
double, double, double, double, double, double, double, double, int,
double, char const* const*)@plt () from
/srv/www/apps/ogr-esricurve/lib/libgdal.so.20
#1 0x00007ffff6fadf37 in OGRCircularString::CurveToLine (this=0x10436d0,
dfMaxAngleStepSizeDegrees=0, papszOptions=0x0) at
ogrcircularstring.cpp:677
#2 0x00007ffff6fb04a2 in OGRCompoundCurve::CurveToLineInternal (
this=0x10435e0, dfMaxAngleStepSizeDegrees=0, papszOptions=0x0,
bIsLinearRing=<optimized out>) at ogrcompoundcurve.cpp:357
#3 0x00007ffff6fb55f7 in OGRCurvePolygon::CurvePolyToPoly (this=0x10435b0,
dfMaxAngleStepSizeDegrees=0, papszOptions=0x0) at
ogrcurvepolygon.cpp:578
#4 0x00007ffff6fd7ae2 in OGRGeometryFactory::forceToPolygon
(poGeom=0x10435b0)
at ogrgeometryfactory.cpp:688
#5 0x00007ffff6fd9118 in OGRGeometryFactory::forceTo (poGeom=0x10435b0,
eTargetType=eTargetType at entry=wkbPolygon,
papszOptions=papszOptions at entry=0x0) at ogrgeometryfactory.cpp:4494
#6 0x00007ffff7641bcc in OGRLayer::ConvertGeomsIfNecessary (
this=this at entry=0x2bd3320, poFeature=poFeature at entry=0xf7f790)
at ogrlayer.cpp:576
#7 0x00007ffff7641bf1 in OGRLayer::SetFeature (this=0x2bd3320,
poFeature=0xf7f790) at ogrlayer.cpp:590
#8 0x00007ffff75e25a9 in OGRGeoJSONLayer::AddFeature (this=0x2bd3320,
poFeature=poFeature at entry=0xf7f790) at ogrgeojsonlayer.cpp:513
#9 0x00007ffff75da482 in OGRESRIJSONReader::AddFeature (this=<optimized
out>,
---Type <return> to continue, or q <return> to quit---
poFeature=0xf7f790) at ogresrijsonreader.cpp:287
#10 0x00007ffff75dbcfd in OGRESRIJSONReader::ReadFeatureCollection (
this=this at entry=0x7fffffffd6c0, poObj=<optimized out>)
at ogresrijsonreader.cpp:464
#11 0x00007ffff75dbdfb in OGRESRIJSONReader::ReadLayers
(this=0x7fffffffd6c0,
poDS=0x1679750, eSourceType=<optimized out>) at
ogresrijsonreader.cpp:139
#12 0x00007ffff75defeb in OGRGeoJSONDataSource::LoadLayers (
this=this at entry=0x1679750, poOpenInfo=poOpenInfo at entry=0x7fffffffd860,
nSrcType=nSrcType at entry=eGeoJSONSourceService,
pszUnprefixed=pszUnprefixed at entry=0x15ecd20 "https://maps..."...,
pszJSonFlavor=pszJSonFlavor at entry=0x1c4e628 "ESRIJSON")
at ogrgeojsondatasource.cpp:785
#13 0x00007ffff75dffa0 in OGRGeoJSONDataSource::Open (
this=this at entry=0x1679750, poOpenInfo=poOpenInfo at entry=0x7fffffffd860,
nSrcType=eGeoJSONSourceService, pszJSonFlavor=0x1c4e628 "ESRIJSON")
at ogrgeojsondatasource.cpp:179
#14 0x00007ffff75e133e in OGRESRIFeatureServiceDataset::LoadPage (
this=0x6956e0) at ogrgeojsondriver.cpp:408
#15 0x00007ffff75e14e7 in OGRESRIFeatureServiceDataset::LoadNextPage (
this=<optimized out>) at ogrgeojsondriver.cpp:390
#16 0x00007ffff75e1628 in OGRESRIFeatureServiceLayer::GetNextFeature (
---Type <return> to continue, or q <return> to quit---
this=0x9009c0) at ogrgeojsondriver.cpp:177
#17 0x00007ffff70b90a9 in LayerTranslator::Translate (
this=this at entry=0x7fffffffdd20, poFeatureIn=poFeatureIn at entry=0x0,
psInfo=psInfo at entry=0x29ae270, nCountLayerFeatures=0,
pnReadFeatureCount=pnReadFeatureCount at entry=0x0,
nTotalEventsDone=@0x7fffffffdb58: 0, pfnProgress=0x0, pProgressArg=0x0,
psOptions=0x6960b0) at ogr2ogr_lib.cpp:4392
#18 0x00007ffff70c0779 in GDALVectorTranslate (pszDest=<optimized out>,
hDstDS=hDstDS at entry=0x0, nSrcCount=nSrcCount at entry=1,
pahSrcDS=pahSrcDS at entry=0x7fffffffdeb0,
psOptionsIn=psOptionsIn at entry=0x693b40,
pbUsageError=pbUsageError at entry=0x7fffffffdeac) at ogr2ogr_lib.cpp:3060
#19 0x00000000004019e7 in main (nArgc=<optimized out>, papszArgv=0x693ae0)
at ogr2ogr_bin.cpp:412
In the last two cases (with OLCCurveGeometries set) I see
curveToLineString is being called with a different back trace (related
to OGRGeometryFactory::organizePolygons):
#0 0x00007ffff6f66f50 in OGRGeometryFactory::curveToLineString(double,
double, double, double, double, double, double, double, double, int,
double, char const* const*)@plt () from
/srv/www/apps/ogr-esricurve/lib/libgdal.so.20
#1 0x00007ffff6fadf37 in OGRCircularString::CurveToLine
(this=0x19ce4d0, dfMaxAngleStepSizeDegrees=0, papszOptions=0x0) at
ogrcircularstring.cpp:677
#2 0x00007ffff6fb04a2 in OGRCompoundCurve::CurveToLineInternal
(this=0x19ce3e0, dfMaxAngleStepSizeDegrees=0, papszOptions=0x0,
bIsLinearRing=<optimized out>) at ogrcompoundcurve.cpp:357
#3 0x00007ffff6fd2f95 in OGRGeometryFactory::organizePolygons
(papoPolygons=papoPolygons at entry=0x19ce390,
nPolygonCount=nPolygonCount at entry=2,
pbIsValidGeometry=pbIsValidGeometry at entry=0x0,
papszOptions=papszOptions at entry=0x0) at ogrgeometryfactory.cpp:1537
#4 0x00007ffff75daff7 in OGRESRIJSONReadPolygon
(poObj=poObj at entry=0x1e50050) at ogresrijsonreader.cpp:1070
#5 0x00007ffff75db761 in OGRESRIJSONReader::ReadGeometry
(this=this at entry=0x7fffffffd6c0, poObj=poObj at entry=0x1e50050) at
ogresrijsonreader.cpp:307
#6 0x00007ffff75db990 in OGRESRIJSONReader::ReadFeature
(this=this at entry=0x7fffffffd6c0, poObj=poObj at entry=0x1e4a590) at
ogresrijsonreader.cpp:415
#7 0x00007ffff75dbcf2 in OGRESRIJSONReader::ReadFeatureCollection
(this=this at entry=0x7fffffffd6c0, poObj=<optimized out>)
at ogresrijsonreader.cpp:463
#8 0x00007ffff75dbdfb in OGRESRIJSONReader::ReadLayers
(this=0x7fffffffd6c0, poDS=0x3433f70, eSourceType=<optimized out>)
at ogresrijsonreader.cpp:139
#9 0x00007ffff75defeb in OGRGeoJSONDataSource::LoadLayers
(this=this at entry=0x3433f70, poOpenInfo=poOpenInfo at entry=0x7fffffffd860,
nSrcType=nSrcType at entry=eGeoJSONSourceService,
pszUnprefixed=pszUnprefixed at entry=0x2c2f680 "https://maps...."...,
pszJSonFlavor=pszJSonFlavor at entry=0x1011c48 "ESRIJSON") at
ogrgeojsondatasource.cpp:785
#10 0x00007ffff75dffa0 in OGRGeoJSONDataSource::Open
(this=this at entry=0x3433f70, poOpenInfo=poOpenInfo at entry=0x7fffffffd860,
nSrcType=eGeoJSONSourceService, pszJSonFlavor=0x1011c48 "ESRIJSON")
at ogrgeojsondatasource.cpp:179
#11 0x00007ffff75e133e in OGRESRIFeatureServiceDataset::LoadPage
(this=0x6956e0) at ogrgeojsondriver.cpp:408
#12 0x00007ffff75e14e7 in OGRESRIFeatureServiceDataset::LoadNextPage
(this=<optimized out>) at ogrgeojsondriver.cpp:390
#13 0x00007ffff75e1628 in OGRESRIFeatureServiceLayer::GetNextFeature
(this=0x9009c0) at ogrgeojsondriver.cpp:177
#14 0x00007ffff70b90a9 in LayerTranslator::Translate
(this=this at entry=0x7fffffffdd20, poFeatureIn=poFeatureIn at entry=0x0,
psInfo=psInfo at entry=0x2bb59c0, nCountLayerFeatures=0,
pnReadFeatureCount=pnReadFeatureCount at entry=0x0,
nTotalEventsDone=@0x7fffffffdb58: 6000,
pfnProgress=0x0, pProgressArg=0x0, psOptions=0x6960b0) at
ogr2ogr_lib.cpp:4392
#15 0x00007ffff70c0779 in GDALVectorTranslate (pszDest=<optimized out>,
hDstDS=hDstDS at entry=0x0, nSrcCount=nSrcCount at entry=1,
pahSrcDS=pahSrcDS at entry=0x7fffffffdeb0,
psOptionsIn=psOptionsIn at entry=0x693b40,
pbUsageError=pbUsageError at entry=0x7fffffffdeac)
at ogr2ogr_lib.cpp:3060
#16 0x00000000004019e7 in main (nArgc=<optimized out>,
papszArgv=0x693ae0) at ogr2ogr_bin.cpp:412
(gdb) cont
Continuing.
More information about the gdal-dev
mailing list