本文整理汇总了Python中ogrtools.ogrtransform.ogrconfig.OgrConfig.transform_reverse方法的典型用法代码示例。如果您正苦于以下问题:Python OgrConfig.transform_reverse方法的具体用法?Python OgrConfig.transform_reverse怎么用?Python OgrConfig.transform_reverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogrtools.ogrtransform.ogrconfig.OgrConfig
的用法示例。
在下文中一共展示了OgrConfig.transform_reverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ili_to_gml
# 需要导入模块: from ogrtools.ogrtransform.ogrconfig import OgrConfig [as 别名]
# 或者: from ogrtools.ogrtransform.ogrconfig.OgrConfig import transform_reverse [as 别名]
def test_ili_to_gml():
trans = OgrConfig(
config="tests/data/np/NP_73_CH_de_ili2.cfg",
ds="tests/data/np/NP_Example.xtf,tests/data/np/NP_73_CH_de_ili2.imd")
__, dstfile = tempfile.mkstemp(suffix='.gml')
os.remove(dstfile)
trans.transform(dstfile, "GML")
print dstfile
gml = codecs.open(dstfile, encoding='utf-8').read()
# GML -> XTF
__, xtffile = tempfile.mkstemp(suffix='.xtf')
trans.transform_reverse(xtffile + ",tests/data/np/NP_73_CH_de_ili2.imd")
print xtffile
xtf = codecs.open(xtffile, encoding='utf-8').read()
zonentyp_kt = """<Nutzungsplanung.Nutzungsplanung.Grundnutzung_Zonentyp_Kt TID="xz4e43cb280000000a">
<Identifikator>142</Identifikator>
<Zonentyp_Kt>Kernzone</Zonentyp_Kt>
<Abkuerzung>K</Abkuerzung>
<Bemerkungen>Kernzone</Bemerkungen>
<Hauptnutzung_CH>Bauzonen_1.Zentrumszonen_14</Hauptnutzung_CH>
<Zonentyp_SIA>Zentrumszonen_14.Kernzone_142</Zonentyp_SIA>
</Nutzungsplanung.Nutzungsplanung.Grundnutzung_Zonentyp_Kt>"""
assert zonentyp_kt in xtf
assert "<COORD><C1>694511.547</C1><C2>247816.271</C2></COORD>" in xtf
geometry_type = """<Geometrie>
<SURFACE>
<BOUNDARY>
<POLYLINE>
<COORD>"""
assert geometry_type in xtf
# XTF -> GML
option = gdal.GetConfigOption('OGR_STROKE_CURVE')
gdal.SetConfigOption('OGR_STROKE_CURVE', 'True')
trans2 = OgrConfig(config="tests/data/np/NP_73_CH_de_ili2.cfg",
ds=xtffile + ",tests/data/np/NP_73_CH_de_ili2.imd")
__, gmlfile2 = tempfile.mkstemp(suffix='.gml')
trans.transform(gmlfile2, "GML")
print gmlfile2
gml2 = codecs.open(gmlfile2, encoding='utf-8').read()
gml = re.sub(r'tmp.+.xsd', 'tmpXXX.xsd', gml, count=1)
gml2 = re.sub(r'tmp.+.xsd', 'tmpXXX.xsd', gml2, count=1)
assert gml == gml2
# cleanup
os.remove(dstfile)
os.remove(xtffile)
os.remove(gmlfile2)
gdal.SetConfigOption('OGR_STROKE_CURVE', option)
示例2: test_geojson_reverse_to_ili
# 需要导入模块: from ogrtools.ogrtransform.ogrconfig import OgrConfig [as 别名]
# 或者: from ogrtools.ogrtransform.ogrconfig.OgrConfig import transform_reverse [as 别名]
def test_geojson_reverse_to_ili():
#ogr transform --format GeoJSON --config tests/data/ili/RoadsExdm2ien.cfg tests/data/ili/RoadsExdm2ien_streetaxis.json tests/data/ili/roads23.xtf,tests/data/ili/RoadsExdm2ien.imd streetaxis
trans = OgrConfig(config="tests/data/ili/RoadsExdm2ien.cfg",
ds="tests/data/ili/RoadsExdm2ien_streetaxis.json")
__, dstfile = tempfile.mkstemp(suffix='.xtf')
#os.remove(dstfile)
trans.transform_reverse(dstfile + ",tests/data/ili/RoadsExdm2ien.imd",
layers=["RoadsExdm2ien.RoadsExtended.StreetAxis"])
print dstfile
result = codecs.open(dstfile, encoding='utf-8').read()
expected = """<DATASECTION>
<RoadsExdm2ien.RoadsExtended BID="RoadsExdm2ien.RoadsExtended">
<RoadsExdm2ien.RoadsExtended.StreetAxis TID="8">
<Geometry>
<POLYLINE>
<COORD><C1>55.6</C1><C2>37.649</C2></COORD>
<COORD><C1>15.573</C1><C2>25.785</C2></COORD>
</POLYLINE>
</Geometry>
<Street>1</Street>
<Precision>precise</Precision>
</RoadsExdm2ien.RoadsExtended.StreetAxis>"""
assert expected in result
os.remove(dstfile)