示例#1
0
 def test_hash_point(self):  # TODO: Put this test elsewhere!
     # TODO: This is a smoke test.
     p1 = Point.from_coordinates(x=91.5,
                                 y=-46.1,
                                 z=1.0,
                                 spatial_reference=4326)
     h1 = p1.djiohash()
     print(h1)
     p2 = Point.from_coordinates(x=91.5,
                                 y=-46.1,
                                 z=1.0,
                                 spatial_reference=4326)
     h2 = p2.djiohash()
     print(h2)
     p3 = Point.from_coordinates(x=91.6,
                                 y=-46.1,
                                 z=1.0,
                                 spatial_reference=4326)
     h3 = p3.djiohash()
     print(h3)
     p4 = Point.from_coordinates(x=-46.1,
                                 y=91.6,
                                 z=1.0,
                                 spatial_reference=4326)
     h4 = p4.djiohash()
     print(h4)
     p5 = Point.from_coordinates(x=91.5, y=-46.1, spatial_reference=4326)
     h5 = p5.djiohash()
     print(h5)
     self.assertEqual(h1, h2)
     self.assertNotEqual(h1, h3)
     self.assertNotEqual(h1, h4)
     self.assertNotEqual(h1, h5)
示例#2
0
 def test_init_flipCoordinates_coordsFlipped(self):
     p = Point.from_coordinates(x=100.1, y=200.2, spatial_reference=3857)
     self.assertEqual(100.1, p.x)
     self.assertEqual(200.2, p.y)
     q = p.flip_coordinates()
     self.assertEqual(200.2, q.x)
     self.assertEqual(100.1, q.y)
示例#3
0
 def test_pointToGml_verify(self):
     p = Point.from_coordinates(x=91.5, y=-46.1, spatial_reference=4326)
     self.assertEqual(
         """<gml:Point srsName="EPSG:4326"><gml:coordinates>91.5,-46.1</gml:coordinates></gml:Point>""",
         p.to_gml(version=2)
     )
     self.assertEqual(
         """<gml:Point srsName="urn:ogc:def:crs:EPSG::4326"><gml:pos>-46.1 91.5</gml:pos></gml:Point>""",
         p.to_gml(version=3)
     )
示例#4
0
 def test_toPointTuple_verify(self):
     p = Point.from_coordinates(x=91.5, y=-46.1, z=1.0,
                                spatial_reference=4326)
     p_tuple = p.to_point_tuple()
     self.assertEqual(91.5, p_tuple.x)
     self.assertEqual(-46.1, p_tuple.y)
     self.assertEqual(1.0, p_tuple.z)
     self.assertEqual(4326, p_tuple.srid)
     # Create another tuple to make sure that we get the cached instance.
     p_tuple_2 = p.to_point_tuple()
     self.assertTrue(p_tuple_2 == p_tuple)
示例#5
0
 def test_init_add_toPolyline(self):
     # Create the proto-geometry.  When it's time comes, it'll be projected to UTM zone 15.
     proto: ProtoGeometry = ProtoGeometry(spatial_reference=26915)
     # Add a lat/lon.
     proto.add(LatLonTuple(latitude=46.5, longitude=-94.1))
     # Add a Point in the adjacent UTM zone.
     proto.add(Point.from_coordinates(x=492326.81, y=5149608.22, spatial_reference=26916))
     # Add a web-mercator point as a PointTuple.
     proto.add(PointTuple(-10475164.0836, y=5700582.7324, z=0.0, srid=3857))
     # Tell the proto-geometry to give us a Polyline.
     p: Polyline = proto.to_polyline()
     # There you go.
     self.assertEqual(GeometryType.POLYLINE, p.geometry_type)
     self.assertEqual(26915, p.spatial_reference.srid)
示例#6
0
 def test_init_add_toPolygon(self):
     # Create the proto-geometry.  When it's time comes, it'll be projected to UTM zone 15.
     proto: ProtoGeometry = ProtoGeometry(spatial_reference=26915)
     # Add a lat/lon.
     proto.add(LatLonTuple(latitude=46.5, longitude=-94.1))
     # Add a Point in the adjacent UTM zone.
     proto.add(Point.from_coordinates(x=492326.81, y=5149608.22, spatial_reference=26916))
     # Add a web-mercator point as a PointTuple.
     proto.add(PointTuple(-10475164.0836, y=5700582.7324, z=0.0, srid=3857))
     # Tell the proto-geometry to give us a Polygon.
     p: Polyline = proto.to_polygon()
     # There you go.
     self.assertEqual(GeometryType.POLYGON, p.geometry_type)
     self.assertEqual(26915, p.spatial_reference.srid)
     # TODO: Add more test criteria.
     # self.assertEqual(
     #     '<gml:Polygon srsName="urn:ogc:def:crs:EPSG::26915"><gml:exterior><gml:LinearRing><gml:posList>' + \
     #     '415595.186865569 5150191.11554508 952676.147829255 5166538.99156226 414060.603356157 5039084.94282137' +
     #     ' 415595.186865569 5150191.11554508</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>',
     #     p.to_gml()
     # )
示例#7
0
 def test_transformToUtm_verifyTargetSrid(self):
     p = Point.from_lat_lon(latitude=41.885921, longitude=-82.968750)
     q = p.transform_to_utm()
     self.assertEqual(26917, q.spatial_reference.srid)
示例#8
0
 def test_transform_verifyTargetSrid(self):
     p = Point.from_coordinates(x=91.5, y=-46.1, spatial_reference=4326)
     q = p.transform(spatial_reference=3857)
     self.assertEqual(3857, q.spatial_reference.srid)
示例#9
0
 def test_init_geometryType_point(self):
     point: Point = Point.from_coordinates(x=100.1, y=45.2, spatial_reference=4326)
     self.assertEqual(point.geometry_type, GeometryType.POINT)