def __init__(self, name=None, fields=[], ft=None, uri='http://geoscript.org/feature'): self._type = ft if name and fields: # name and fields specified directly, generate gt feature type # from list tb = SimpleFeatureTypeBuilder() tb.setName(NameImpl(name)) tb.setNamespaceURI(uri) for fld in fields: if isinstance(fld, Field): name, typ, prj = fld.name, fld.typ, fld.proj else: name, typ = fld[0], fld[1] prj = None if issubclass(typ, geom.Geometry): # look for srs/crs info if len(fld) > 2: prj = proj.Projection(fld[2]) prj = prj if prj else proj.Projection('EPSG:4326') if prj: tb.crs(prj._crs) # we call map() here to avoid setting the type binding to a Python # (eg: PyInteger) type, but rather a native java type (Integer) tb.add(name, core.map(typ)) self._type = tb.buildFeatureType() elif ft: # gt feature type specified directly self._type = ft else: raise Exception('No fields specified for feature type.')
def __init__(self, name=None, fields=[], ft=None, uri='http://geoscript.org/feature'): self._type = ft if name and fields: # name and fields specified directly, generate gt feature type # from list tb = SimpleFeatureTypeBuilder() tb.setName(NameImpl(name)) tb.setNamespaceURI(uri) for fld in fields: if isinstance(fld, Field): name, typ, prj = fld.name, fld.typ, fld.proj else: name, typ = fld[0], fld[1] prj = None if issubclass(typ, geom.Geometry): # look for srs/crs info if len(fld) > 2: prj = proj.Projection(fld[2]) prj = prj if prj else proj.Projection('EPSG:4326') if prj: tb.crs(prj._crs) # we call unmap() here to avoid setting the type binding to a Python # (eg: PyInteger) type, but rather a native java type (Integer) tb.add(name, core.unmap(typ)) self._type = tb.buildFeatureType() elif ft: # gt feature type specified directly self._type = ft else: raise Exception('No fields specified for feature type.')