Beispiel #1
0
 def test_unshape_geo_hash(self):
     """Test unshaping from PostGIS objects to EWKT"""
     print('##### TEST2 #####')
     r1 = select([Xco2]).where(Xco2.id == self.test_point_pk)
     r = self.conn.execute(r1).first()
     try:
         spatial.unshape_geo_hash(r[3])
         print('PASSED')
     except Exception as e:
         print('FAILED')
         raise e
 def test_unshape_geo_hash(self):
     """Test unshaping from PostGIS objects to EWKT"""
     print('##### TEST2 #####')
     r1 = select([Xco2]).where(Xco2.id == self.test_point_pk)
     r = self.conn.execute(r1).first()
     try:
         spatial.unshape_geo_hash(r[3])
         print('PASSED')
     except Exception as e:
         print('FAILED')
         raise e
Beispiel #3
0
    def initialize_geojson(cls, point):
        """
        Return a GeoJSON with only one point, the center of the AoI.

        :param point: a center point of a AoI
        :return: a GeoJSON containing only the center point
        """
        x, y = spatial.unshape_geo_hash(point)
        xco2 = cls._connected(
            'SELECT xco2 from t_co2 WHERE pixels = %s',
            **{
                'values': (point, )
            }
        )[0]
        # store initialized geojson with center
        # as the only feature-point
        return {
            "features": [{
              "type": "Feature",
              "geometry": {
                "type": "Point",
                "coordinates": [x, y]
              },
              "properties": {
                "xco2": xco2
              }
            }]
        }
Beispiel #4
0
    def serialize_geojson(cls, points_tuple):
        """
        Return a GeoJson from a sequence of tuples.

        :param points_tuple: a sequence of Xco2 points.
        :return: a GeoJSON with the co2 data for the points
        """
        geojson = {
            "features": []
        }
        for p in points_tuple:
            x, y = spatial.unshape_geo_hash(p[3])
            xco2 = p[1]
            # store initialized geojson with center
            # as the only feature-point
            geojson["features"].append({
              "type": "Feature",
              "geometry": {
                "type": "Point",
                "coordinates": [x, y]
              },
              "properties": {
                "xco2": xco2
              }
            })
        return geojson
Beispiel #5
0
    def initialize_geojson(cls, point):
        """
        Return a GeoJSON with only one point, the center of the AoI.

        :param point: a center point of a AoI
        :return: a GeoJSON containing only the center point
        """
        x, y = spatial.unshape_geo_hash(point)
        xco2 = cls._connected('SELECT xco2 from t_co2 WHERE pixels = %s',
                              **{'values': (point, )})[0]
        # store initialized geojson with center
        # as the only feature-point
        return {
            "features": [{
                "type": "Feature",
                "geometry": {
                    "type": "Point",
                    "coordinates": [x, y]
                },
                "properties": {
                    "xco2": xco2
                }
            }]
        }
Beispiel #6
0
    def serialize_geojson(cls, points_tuple):
        """
        Return a GeoJson from a sequence of tuples.

        :param points_tuple: a sequence of Xco2 points.
        :return: a GeoJSON with the co2 data for the points
        """
        geojson = {"features": []}
        for p in points_tuple:
            x, y = spatial.unshape_geo_hash(p[3])
            xco2 = p[1]
            # store initialized geojson with center
            # as the only feature-point
            geojson["features"].append({
                "type": "Feature",
                "geometry": {
                    "type": "Point",
                    "coordinates": [x, y]
                },
                "properties": {
                    "xco2": xco2
                }
            })
        return geojson