Пример #1
0
    def from_node(cls, node, xml_ns, ns_key=None, kwargs=None):
        if xml_ns is None or 'sfa' not in xml_ns:
            raise ValueError('xml_ns must contain an entry for key "sfa"')

        coords = cls._deserialize_point(node, xml_ns, 'Point')
        if coords is not None:
            return cls(Point=PointType(coordinates=coords))

        coords = cls._deserialize_line(node, xml_ns, tag='Line')
        if coords is not None:
            return cls(Line=LineStringType(coordinates=coords))

        coords = cls._deserialize_line(node, xml_ns, tag='LinearRing')
        if coords is not None:
            return cls(LinearRing=LinearRingType(coordinates=coords))

        coords = cls._deserialize_polygon(node, xml_ns, tag='Polygon')
        if coords is not None:
            return cls(Polygon=PolygonType(coordinates=coords))

        coords = cls._deserialize_line(node, xml_ns, tag='MultiPoint')
        if coords is not None:
            return cls(MultiPoint=MultiPointType(coordinates=coords))

        coords = cls._deserialize_multilinestring(node, xml_ns, tag='MultiLineString')
        if coords is not None:
            return cls(MultiLineString=MultiLineStringType(coordinates=coords))

        coords = cls._deserialize_multipolygon(node, xml_ns, tag='MultiPolygon')
        if coords is not None:
            return cls(MultiPolygon=MultiPolygonType(coordinates=coords))

        return cls()
Пример #2
0
 def Line(self, value):
     if value is None:
         self._Line = None
     elif isinstance(value, (numpy.ndarray, list, tuple)):
         self._Line = LineStringType(coordinates=value)
     elif isinstance(value, LineStringType):
         self._Line = value
     else:
         raise TypeError(
             'Line requires and instance of sarpy.geometry.geometry_elements.LineString, '
             'got {}'.format(type(value)))