Exemple #1
0
    def maybe(cls, x, degrees=False):
        """ Convert list or tuple to Cartesian2 """
        if isinstance(x, Cartesian2):
            return x

        x = shapefile._maybe_shapely_point(x)
        if com.is_listlike(x) and len(x) == 2:
            return Cartesian2(*x, degrees=degrees)
        return x
Exemple #2
0
    def maybe(cls, x, degrees=False):
        """ Convert list or tuple to Cartesian2 """
        if isinstance(x, Cartesian2):
            return x

        x = shapefile._maybe_shapely_point(x)
        if com.is_listlike(x) and len(x) == 2:
            return Cartesian2(*x, degrees=degrees)
        return x
Exemple #3
0
    def maybe(cls, x, degrees=False):
        """ Convert list or tuple to Cartesian3 """
        if isinstance(x, Cartesian3):
            return x

        x = shapefile._maybe_shapely_point(x)

        # currently, only Cartesian3 tries to geocode passed loc
        x = geocode._maybe_geocode(x, height=0)
        if com.is_listlike(x):
            if len(x) == 3:
                return Cartesian3(*x, degrees=degrees)
            elif len(x) == 2 and degrees:
                # if degrees is True, z can filled by 0
                # otherwise raise (non-degrees Cartesian is used in Box)
                return Cartesian3(x=x[0], y=x[1], z=0, degrees=degrees)
        return x
Exemple #4
0
    def maybe(cls, x, degrees=False):
        """ Convert list or tuple to Cartesian3 """
        if isinstance(x, Cartesian3):
            return x

        x = shapefile._maybe_shapely_point(x)

        # currently, only Cartesian3 tries to geocode passed loc
        x = geocode._maybe_geocode(x, height=0)
        if com.is_listlike(x):
            if len(x) == 3:
                return Cartesian3(*x, degrees=degrees)
            elif len(x) == 2 and degrees:
                # if degrees is True, z can filled by 0
                # otherwise raise (non-degrees Cartesian is used in Box)
                return Cartesian3(x=x[0], y=x[1], z=0, degrees=degrees)
        return x