OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.79k stars 2.51k forks source link

Preserve GML mixed segment type when converting to other format #4186

Closed tom62291 closed 3 years ago

tom62291 commented 3 years ago

Hi,

I have a sample geometry in the "sample.gml" file like:

<gml:surfaceProperty>
<gml:Surface srsName="EPSG:2326" srsDimension="2">
<gml:patches>
<gml:PolygonPatch>
<gml:exterior>
<gml:Ring>
<gml:curveMember>
<gml:Curve>
<gml:segments>
<gml:LineStringSegment>
<gml:posList>821502.753690919 838825.332031005 821381.210113175 838710.41453058 821360.912615186 838729.847662167 821325.056860002 838766.388160001 821317.618590001 838773.951390002 821306.383070005 838784.513530002 821299.884140005 838791.502490001 821296.827230005 838794.559400002 821287.026380004 838805.70786 821276.858000001 838817.346380001 821253.126160003 838847.316420002 821244.07817 838856.61344 821225.816160005 838872.634200003 821210.874520004 838887.824870002 821209.657080004 838888.660990002 821197.999220006 838900.406510001 821196.679960005 838902.351460001 821175.263610004 838924.514900002 821173.368710004 838926.001200002 821162.499730004 838936.870190001 821161.212100003 838939.647350002 821158.187990002 838942.842460002 821150.865601303 838950.325426901 821183.763985788 838983.207224775 821213.369789001 838993.285796082 821220.415840006 839013.602080001 821222.458913533 839025.097476903 821203.058640001 839037.457540001 821194.727830006 839043.611480001</gml:posList>
</gml:LineStringSegment>
<gml:ArcByCenterPoint numArc="1">
<gml:posList>821194.396688321 839052.616490606</gml:posList>
<gml:radius uom="EPSG:2326">9.01109709191771</gml:radius>
<gml:startAngle uom="degree">177.894008505116</gml:startAngle>
<gml:endAngle uom="degree">250.98396509322</gml:endAngle>
</gml:ArcByCenterPoint>
<gml:LineStringSegment>
<gml:posList>821185.877350006 839049.680380003 821179.195600005 839077.573800002 821182.889330002 839102.031640002 821182.508110249 839145.995286149 821119.131996101 839146.917732067 821096.763 839147.243000001 821081.112000002 839151.318000001 821067.199000003 839158.275 821053.181000002 839166.945 821038.372000003 839173.780000001 821019.893000001 839179.841000001 821005.980000002 839180.883000001 820992.807000002 839179.475 820984.454000002 839177.577 820969.1285 839171.287 820964.329000002 839168.464000002 820956.936000001 839162.449000002 820606.668 838831.312000001 820572.801999999 838831.138000002 820545.847999999 838829.177000001 820527.716 838826.726000002 820513.541999999 838872.231 820502.622000001 838866.949000001 820488.66 838862.415000001 820475.457 838860.631 820459.225000001 838860.631 820444.837000003 838864.794000001 820432.032 838872.161000001 820422.818000002 838882.906 820414.040000001 838900.166 820412.445000002 838910.046000001 820413.518000001 838921.945000001 820420.469000001 838951.063 820421.696 838970.970000001 820420.236 838987.546000002 820413.461000001 839005.795 820404.981000001 839018.881000001 820326.302000001 839100.932000001 820264.013000002 839159.337000001 820259.048000002 839161.521000001 820208.392999999 839163.506 820204.421000004 839166.087 820151.306000002 839221.800000001 820152.697000002 839267.856000001 820110.981000001 839310.745 820008.075115504 839386.140157646 819828.164999999 839517.954000001 819809.985000003 839536.135000001 819794.283 839555.141999999 819783.540000003 839576.628 819776.101000002 839596.461000001 819769.491 839617.948 819762.880000001 839646.045 819760.401000002 839678.275000001 819671.150000002 839770.005 819638.094000004 839739.428 819611.026000001 839764.856 819503.68 839663.284000001 819433.115000002 839731.726000001 819275.293 839574.726000001 819013.104 839846.068000001 818987.465000002 839876.780000001 818955.790000001 839922.643 818943.898000002 839945.475000001 818934.805 839974.841000001 818962.085999999 840001.478999999 818977.295000002 839986.443 819001.873000002 840010.834000001 818912.536000002 840103.213 818796.276000002 840226.479 818790.215000002 840231.53 818779.101000002 840237.591 818766.979000002 840241.632000002 818760.918000003 840242.642000002 818737.682000002 840242.137000002 818721.517999997 840239.612 818716.466000002 840239.612 818655.851000002 840229.003000001 818447.375 840431.5 818240.236000003 840642.849000002 817417.700999999 840648.712000001 817521.161570216 840470.178754702 817926.575000003 839770.59 818000.000000002 839769.636000001 818181.378999999 839767.282000001 819020.631000001 838847.751 819374.232999997 838460.325000001 819729.337000003 838218.262 819937.778000005 838076.174000002 819946.902000003 838080.383 819950.725000001 838071.954 819971.001000004 838081.153000001 819967.374 838089.114 819975.727 838092.920000001 819979.492000001 838085.094000001 820004.313000001 838096.436000001 820004.000000004 838101.375000001 820008.687000001 838103.375 820013.636000002 838100.769 820013.691 838100.649 820067.645000001 838125.304 820062.975 838135.434 820073.435000001 838140.224 820076.055000003 838134.903000001 820100.153999999 838145.974000001 820102.365 838141.444000001 820148.654000001 838162.854 820193.204999998 838241.223 820224.493000003 838197.859 820232.529999999 838190.785 820234.479000002 838189.424 820236.946 838187.701000001 820241.110999998 838184.791000001 820245.262 838181.892000001 820247.700000003 838180.190000001 820249.427000001 838178.985000001 820250.836999999 838177.999000001 820270.155000003 838164.510000001 820271.124000002 838163.499 820279.425999999 838154.871000001 820342.674000001 838087.903000001 820347.715000002 838076.822000001 820354.471999999 838061.971 820355.062999999 838061.063000001 820400.000000002 837964.349000001 820442.437999999 837873.015000001 820452.949999999 837863.700000002 820457.32 837857.420000002 820461.9 837851.660000001 820464.950000003 837848.28 820469.050000003 837844.05 820477.900000002 837836.95 820484.200000001 837832.75 820514.798999999 837814.546 820533.199999997 837803.600000001 820536.070000002 837801.760000001 820541.457 837797.608000001 820545.68 837793.77 820549.350000001 837789.750000001 820552.590000004 837785.430000001 820555.710000001 837780.210000001 820559.060000004 837773.27 820560.970000003 837767.590000001 820561.740000002 837764.250000001 820562.279999999 837760.87 820562.810000001 837753.75 820562.810000001 837747.690000001 820560.270000003 837701.110000002 820560.139999999 837694.250000002 820560.310000002 837687.480000001 820561.149999999 837679.170000001 820562.010000004 837674.23 820563.120000001 837669.340000001 820564.91 837662.900000001 820566.290000001 837658.66 820569.489999998 837650.340000001 820571.900000002 837644.870000001 820574.500000002 837639.490000002 820577.289999999 837634.200000001 820580.370000001 837628.99 820583.369999999 837624.85 820586.030000001 837621.730000001 820588.890000002 837618.810000001 820592.740000002 837615.450000001 820596.939999999 837612.390000001 820600.67 837610.09 820605.560000002 837607.59 820610.640000002 837605.52 820615.880000003 837603.9 820620.91 837602.82 820625.930000002 837602.2 820630.99 837602.02 820635.029999999 837602.190000001 820640.706000002 837602.609000001 820647.164000003 837604.597 820667.665000001 837611.375000002 820693.504000003 837620.092 820706.562999999 837618.766 820723.492000001 837620.177000001 820737.800999999 837623.805 820758.453 837631.923 820818.639 837661.354000002 820850.303000001 837678.294000001 820859.802000001 837684.151000002 820869.934000002 837691.909 820887.032 837706.474000002 820905.714000003 837726.105000002 820935.693000002 837760.753 820989.269000001 837742.474 820997.750000002 837773.999999999 821007.687000003 837790.125 821015.687000003 837801.375 821058.687000003 837850.625 821077.5 837871.250000001 821265.398000002 838051.123500001 821403.73 838184.495000001 821412.898 838196.455000002 821423.128000002 838214.991 821433.732999999 838259.549000001 821446.950000001 838303.965000001 821453.922 838317.718 821461.910000004 838329.185000001 821469.26 838337.428000001 821476.828000003 838343.885000001 821545.641000003 838384.52 821578.048000002 838407.955 821589.234000001 838418.179000001 821596.028000005 838426.672000001 821602.258797349 838436.698108078 821624.642999999 838472.718000001 821643.830999998 838508.11 821793.187000003 838887.125000001 821802.250000002 838918.875 821807.437000001 838948.375000001 821809.500000004 838975.312 821809.25 838999.312000001 821807.125 839023.187 821802.625 839047.437000001 821744.952102466 839029.270855344 821731.803863645 839025.12934662 821721.95516387 839018.157769452 821708.55458211 839008.234529218 821694.079088213 838994.520607631 821661.411050001 838961.513310001 821544.12524298 838863.312472236 821502.753690919 838825.332031005</gml:posList>
</gml:LineStringSegment>
</gml:segments>
</gml:Curve>
</gml:curveMember>
</gml:Ring>
</gml:exterior>
</gml:PolygonPatch>
</gml:patches>
</gml:Surface>
</gml:surfaceProperty>

When I try ogr2ogr -f GML convert.gml sample.gml, the segments will lineaerized to <gml:LinearRing><gml:posList>, or when I convert that GML to FGDB, the segments also become linear line string.

May I know is technical feasible to preseve GML mixed segment type when converting to other format?

jratike80 commented 3 years ago

You should not ask questions in the bug tracker but use gdal-dev mailing list instead. But while you are here could you add a complete gml file that can be opened with ogrinfo/ogr2ogr as an annex?

Depending on your GDAL version the ogr2ogr option -f GML may write GML 2 that does not support curved geometries. See https://gdal.org/drivers/vector/gml.html and use explicit -dsco FORMAT=GML3.2 to be sure what format is written.

There is no general answer about conversion "to other format". Quite few formats support any sort of curved geometries. Geopackage driver is documented to support multisurface https://gdal.org/drivers/vector/gpkg.html but I do not know what is the situation with fgdb driver. GML seems to support many segment types and some of them feel rather exotic http://www.datypic.com/sc/niem31/e-ns76_segments.html.

If you need advanced non-linear geometries it might be best to use GML as long as possible, and if you need other formats, study the capabilities of the format and corresponding GDAL driver.

rouault commented 3 years ago

Starting with the development version (3.4dev), FORMAT=GML3.2 is the default, and the curve polygon is preserved when doing ogr2ogr, using an equivalent for the circular portion (the OGR geometry model uses the equivalent of ArcString, and on ingestion of ArcByCenterPoint transforms that to that representation) The FileGDB driver doesn't support currently writing curve geometries. It could be likely enhanced to do that, but that's another story.