Esempio n. 1
0
    def fromDegreesArray(cls, x):
        # convert shaply.Polygon to coordinateslist
        x = shapefile._maybe_shapely_polygon(x)
        x = shapefile._maybe_shapely_line(x)
        x = geocode._maybe_geocode(x, height=0)

        if com.is_listlike_2elem(x):
            x = com._flatten_list_of_listlike(x)
        elif com.is_listlike_3elem(x):
            raise NotImplementedError

        return Cartesian3Array(x)
Esempio n. 2
0
    def fromDegreesArray(cls, x):
        # convert shaply.Polygon to coordinateslist
        x = shapefile._maybe_shapely_polygon(x)
        x = shapefile._maybe_shapely_line(x)
        x = geocode._maybe_geocode(x, height=0)

        if com.is_listlike_2elem(x):
            x = com._flatten_list_of_listlike(x)
        elif com.is_listlike_3elem(x):
            raise NotImplementedError

        return Cartesian3Array(x)
Esempio n. 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
Esempio n. 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
Esempio n. 5
0
    def flyTo(self, destination, orientation=None):
        from cesiumpy.entities.entity import _CesiumEntity
        import cesiumpy.extension.geocode as geocode

        if isinstance(destination, _CesiumEntity):
            # if entity has a position (not positions), use it
            if destination.position is not None:
                destination = destination.position

        destination = geocode._maybe_geocode(destination, height=100000)

        if com.is_listlike(destination) and len(destination) == 4:
            destination = cartesian.Rectangle.maybe(destination)
        else:
            destination = cartesian.Cartesian3.maybe(destination, degrees=True)
        self.destination = destination
        self.orientation = com.notimplemented(orientation)

        return self
Esempio n. 6
0
    def flyTo(self, destination, orientation=None):
        from cesiumpy.entities.entity import _CesiumEntity
        import cesiumpy.extension.geocode as geocode

        if isinstance(destination, _CesiumEntity):
            # if entity has a position (not positions), use it
            if destination.position is not None:
                destination = destination.position

        destination = geocode._maybe_geocode(destination, height=100000)

        if com.is_listlike(destination) and len(destination) == 4:
            destination = cartesian.Rectangle.maybe(destination)
        else:
            destination = cartesian.Cartesian3.maybe(destination, degrees=True)
        self.destination = destination
        self.orientation = com.notimplemented(orientation)

        return self