Beispiel #1
0
    def __call__(self,s=None):
        """
        A factory method for creating objects of the correct OpenGIS type.
        """
        factory = OGGeoTypeFactory()
        parser = WKBParser(factory)
        parser.parseGeometry(s)

        return factory.getGeometry()
Beispiel #2
0
    def __call__(self,s=None,c=None):
        """
        A factory method for creating objects of the correct OpenGIS type.
        """
        factory = OGGeoTypeFactory()

        # We need to know whether the format of the s is EWKB or HEXEWKB
        # there is no full proof way of doing this so we take a guess
        # In all the cases I have seen the ord of the byte word of an
        # EWKB string is below 32. Because HEXEWKB is a text string it
        # is not possible for the ord of the first character to be below
        # 32. So this is the best way I have.
        try:
            if ord(s[0]) < 32:
                parser = EWKBParser(factory)
            else:
                parser = HEXEWKBParser(factory)
        except:
            # catch the very rare case where s[0] would fail because of the
            # size of the string
            parser = HEXEWKBParser(factory)

        parser.parseGeometry(s)
        return factory.getGeometry()