aheinecke@5004: try:
aheinecke@5004:     from osgeo import ogr
aheinecke@5077: except ImportError:
aheinecke@5004:     import ogr
ingo@2862: 
ingo@2862: from importer import Importer
ingo@2862: 
ingo@2862: TABLE_NAME="gauge_location"
ingo@2862: PATH="Hydrologie/Streckendaten"
ingo@3654: NAME="Gauge locations"
ingo@2862: 
ingo@2862: 
ingo@2862: class GaugeLocation(Importer):
ingo@2862: 
ingo@2862:     def getPath(self, base):
ingo@2862:         return "%s/%s" % (base, PATH)
ingo@2862: 
ingo@2862: 
ingo@2862:     def getTablename(self):
ingo@2862:         return TABLE_NAME
ingo@2862: 
ingo@2862: 
ingo@3654:     def getName(self):
ingo@3654:         return NAME
ingo@3654: 
ingo@3654: 
ingo@2862:     def isGeometryValid(self, geomType):
ingo@2862:         return geomType == 1
ingo@2862: 
ingo@2862: 
ingo@2862:     def isShapeRelevant(self, name, path):
ingo@2862:         return True
ingo@2862: 
ingo@2862: 
ingo@2862:     def createNewFeature(self, featureDef, feat, **args):
ingo@2862:         newFeat  = ogr.Feature(featureDef)
ingo@2862:         geometry = feat.GetGeometryRef()
ingo@2862:         geometry.SetCoordinateDimension(2)
ingo@2862: 
ingo@2862:         newFeat.SetGeometry(geometry)
ingo@2862: 
ingo@2862:         if self.IsFieldSet(feat, "river_id"):
ingo@2862:             newFeat.SetField("river_id", feat.GetField("river_id"))
ingo@2862:         else:
ingo@2862:             newFeat.SetField("river_id", self.river_id)
ingo@2862: 
ingo@2862:         if self.IsFieldSet(feat, "Name"):
ingo@2862:             newFeat.SetField("name", feat.GetField("name"))
ingo@2869:         elif self.IsFieldSet(feat, "MPNAAM"):
ingo@2869:             newFeat.SetField("name", feat.GetField("MPNAAM"))
ingo@2862:         else:
ingo@2862:             newFeat.SetField("name", args['name'])
ingo@2862: 
ingo@2862:         return newFeat
ingo@2862: