Esempio n. 1
0
 def test_dimension_reading(self):
     """
     check dimensions are set correctly
     """
     p = Point((0, 1))
     self.assertFalse(p.dimz)
     self.assertFalse(p.dimm)
     p = Point((0, 1, 2))
     self.assertTrue(p.dimz)
     self.assertFalse(p.dimm)
     p = Point((0, 1, 2, 3))
     self.assertTrue(p.dimz)
     self.assertTrue(p.dimm)
     p = Point((0, 1, 2, 3), dimz=False, dimm=False)
     self.assertTrue(p.dimz)
     self.assertTrue(p.dimm)
     p = Point((0, 1), dimz=True, dimm=True)
     self.assertTrue(p.dimz)
     self.assertTrue(p.dimm)
     p = Point((0, 1), dimz=True)
     self.assertTrue(p.dimz)
     self.assertFalse(p.dimm)
     p = Point((0, 1), dimm=True)
     self.assertFalse(p.dimz)
     self.assertTrue(p.dimm)
     p = Point((0, 1, 2), dimz=True)
     self.assertTrue(p.dimz)
     self.assertFalse(p.dimm)
     p = Point((0, 1, 2), dimm=True)
     self.assertFalse(p.dimz)
     self.assertTrue(p.dimm)
     p = Point((0, 1, 2), dimz=True, dimm=True)
     self.assertTrue(p.dimz)
     self.assertTrue(p.dimm)
Esempio n. 2
0
 def test_mixed_dimensionality(self):
     """
     detect mixed dimensionality in MultiGeometries
     """
     p1 = Point((0, 1, 2))
     p2 = Point((0, 1))
     self.assertRaises(DimensionalityError, MultiPoint, [p1, p2], None)
Esempio n. 3
0
 def test_shapely_dump(self):
     """
     convert to Shapely
     """
     point = Point((123, 123))
     sgeom = point.shapely
     self.assertEquals(sgeom.wkb_hex.upper(), point.wkb.upper())
Esempio n. 4
0
 def test_shape(self):
     """
     access using __geo_interface__ and shape
     """
     point = Point.from_geojson(geojson_pt)
     geom = Geometry.shape(point)
     self.assertEquals(point.__geo_interface__, geom.__geo_interface__)
Esempio n. 5
0
 def test_shapely_dump(self):
     """
     convert to Shapely
     """
     point = Point((123, 123))
     sgeom = point.shapely
     self.assertEqual(sgeom.wkb, point.wkb)
Esempio n. 6
0
  def _execute(self, columns, query):
    rank = 0
    col_geom = 'geom' in columns
    col_addr = 'address' in columns
    col_query = 'query' in columns
    locations = self._get_locations(query)

    for location in locations:
      rank = rank + 1
      row = { 'rank' : rank }
      if col_geom:
        geom = Point((location.latitude, location.longitude, location.altitude), srid=self.srid)
        row['geom'] = geom
      if col_addr:
        row['address'] = location.address
      if col_query:
        row['query'] = query.wkb
      yield row
Esempio n. 7
0
 def test_invalid_point_dimension(self):
     """
     detect extra dimensions in Point creation
     """
     p1 = Point((0, 1, 2, 3))
     self.assertRaises(DimensionalityError, Point, ((0, 1, 2, 3, 4)), None)
Esempio n. 8
0
 def execute(self, quals, columns):
     for i in range(self.num):
         x = random.uniform(self.min_x, self.max_x)
         y = random.uniform(self.min_y, self.max_y)
         point = Point((x, y), srid=self.srid)
         yield {"geom": point}