[Talk-cz] Import of farmland from LPIS

Pavel Machek pavel na ucw.cz
Pondělí Červenec 28 20:42:46 UTC 2014


On Mon 2014-07-28 22:35:11, Pavel Machek wrote:
> Ahoj!
> 
> > pro zajímavost, tvůj skript jsem při zkoumání LPISu nakonec zavrhl, jelikož jsem našel tohle:
> > 
> > http://wiki.openstreetmap.org/wiki/Ogr2osm
> > 
> > Stačí doplnit translation funkci (vypůjčeno z pův. skriptu, v příloze) a veškerou srandu udělá jeden příkaz:
> > 
> > ogr2osm.py PLPIS_233406_KU_KOD_742376.shp -t trn-lpis.py -o ujezd.lpis.osm
> 
> No, stahnul jsem si ogr2osm.py, ale nechce fungovat:
> 
> git clone git://github.com/pnorman/ogr2osm.git
> 
> pavel na amd:~/g/ogr2osm$ ./ogr2osm.py 
>   File "./ogr2osm.py", line 538
>     featuresmap = {feature.geometry : feature for feature in
>   Feature.features}
>                                                 ^
> SyntaxError: invalid syntax
> pavel na amd:~/g/ogr2osm$ python3 ./ogr2osm.py 
>   File "./ogr2osm.py", line 320
>     reproject = lambda(geometry): None
>                       ^
> SyntaxError: invalid syntax
> pavel na amd:~/g/ogr2osm$ 
> 
> To druhy jsem zvladnul nejak osalit, jenze nemam potrebny  balicky pro python3:

Tak vyreseno, ted by to melo bezet pod python 2.6 i 3+
									Pavel

diff --git a/ogr2osm.py b/ogr2osm.py
index 587a5ae..0184262 100755
--- a/ogr2osm.py
+++ b/ogr2osm.py
@@ -317,13 +317,13 @@ def getTransform(layer):
         # Some python magic: skip reprojection altogether by using a dummy
         # lamdba funcion. Otherwise, the lambda will be a call to the OGR
         # reprojection stuff.
-        reproject = lambda(geometry): None
+        reproject = lambda geometry: None
     else:
         destSpatialRef = osr.SpatialReference()
         # Destionation projection will *always* be EPSG:4326, WGS84 lat-lon
         destSpatialRef.ImportFromEPSG(4326)
         coordTrans = osr.CoordinateTransformation(spatialRef, destSpatialRef)
-        reproject = lambda(geometry): geometry.Transform(coordTrans)
+        reproject = lambda geometry: geometry.Transform(coordTrans)
 
     return reproject
 
@@ -535,7 +535,7 @@ def output():
     nodes = [geom for geom in Geometry.geometries if type(geom) == Point]
     ways = [geom for geom in Geometry.geometries if type(geom) == Way]
     relations = [geom for geom in Geometry.geometries if type(geom) == Relation]
-    featuresmap = {feature.geometry : feature for feature in Feature.features}
+    featuresmap = dict([(feature.geometry, feature) for feature in Feature.features])
 
     # Open up the output file with the system default buffering
     with open(options.outputFile, 'w', -1) as f:

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html




Další informace o konferenci talk-cz