aheinecke@5004: try:
aheinecke@5004:     from osgeo import ogr
aheinecke@5077: except ImportError:
aheinecke@5004:     import ogr
ingo@2853: 
ingo@2853: from importer import Importer
ingo@2853: 
ingo@2853: TABLE_NAME="river_axes_km"
ingo@2853: PATH="Geodaesie/Flussachse+km"
ingo@3654: NAME="KMS"
ingo@2853: 
ingo@2853: 
ingo@2853: class KM(Importer):
ingo@2853: 
ingo@2853:     def getPath(self, base):
ingo@2853:         return "%s/%s" % (base, PATH)
ingo@2853: 
ingo@2853: 
ingo@2853:     def getTablename(self):
ingo@2853:         return TABLE_NAME
ingo@2853: 
ingo@2853: 
ingo@3654:     def getName(self):
ingo@3654:         return NAME
ingo@3654: 
ingo@3654: 
ingo@2853:     def isGeometryValid(self, geomType):
ingo@2853:         return geomType == 1
ingo@2853: 
ingo@2853: 
ingo@2853:     def isShapeRelevant(self, name, path):
aheinecke@5197:         return name.lower() == "km"
ingo@2853: 
ingo@2853: 
ingo@2853:     def createNewFeature(self, featureDef, feat, **args):
ingo@2853:         newFeat = ogr.Feature(featureDef)
aheinecke@5356: 
aheinecke@5356:         geometry = feat.GetGeometryRef()
aheinecke@5356:         geometry.SetCoordinateDimension(2)
aheinecke@5356:         newFeat.SetGeometry(geometry)
aheinecke@5356: 
ingo@2861:         newFeat.SetField("name", args['name'])
ingo@2853: 
ingo@2853:         if self.IsFieldSet(feat, "river_id"):
ingo@2853:             newFeat.SetField("river_id", feat.GetField("river_id"))
ingo@2853:         else:
ingo@2853:             newFeat.SetField("river_id", self.river_id)
ingo@2853: 
tom@5886:         if self.IsDoubleFieldSet(feat, "landkm"):
tom@5886:             newFeat.SetField("fedstate_km", feat.GetFieldAsDouble("landkm"))
tom@5886: 
ingo@2853:         if self.IsDoubleFieldSet(feat, "km"):
ingo@2853:             newFeat.SetField("km", feat.GetFieldAsDouble("km"))
ingo@2853:         elif self.IsDoubleFieldSet(feat, "KM"):
ingo@2853:             newFeat.SetField("km", feat.GetFieldAsDouble("KM"))
ingo@2853:         else:
ingo@2853:             return None
ingo@2853: 
ingo@2853:         return newFeat
ingo@2853: