ingo@2862: import ogr
ingo@2862: 
ingo@2862: from importer import Importer
ingo@2862: 
ingo@2862: TABLE_NAME="catchment"
ingo@2862: PATH="Hydrologie/Einzugsgebiet"
ingo@3654: NAME="Catchments"
ingo@2862: 
ingo@2862: 
ingo@2862: class Catchment(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 == 3 or geomType == 6
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@2862:         else:
ingo@2862:             newFeat.SetField("name", args['name'])
ingo@2862: 
ingo@2862:         if self.IsFieldSet(feat, "AREA"):
ingo@2862:             newFeat.SetField("area", feat.GetField("area"))
ingo@2862: 
ingo@2862:         return newFeat
ingo@2862: