summaryrefslogtreecommitdiff
path: root/archaeological_finds/tests.py
diff options
context:
space:
mode:
authorQuentinAndre <quentin.andre@imt-atlantique.net>2021-07-06 17:57:21 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-09-01 12:36:45 +0200
commit168f9a17ffefb4e95d34b394d39537d70210ae84 (patch)
tree448cfe012ae11da0ed465e321a52efbeca1aaa46 /archaeological_finds/tests.py
parent4e1de0371402810fd6927d6053fb4c03f45f6245 (diff)
downloadIshtar-168f9a17ffefb4e95d34b394d39537d70210ae84.tar.bz2
Ishtar-168f9a17ffefb4e95d34b394d39537d70210ae84.zip
get_geo_items + test
Diffstat (limited to 'archaeological_finds/tests.py')
-rw-r--r--archaeological_finds/tests.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index d0adc766a..07e93be96 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -2503,6 +2503,39 @@ class GeomaticTest(FindInit, TestCase):
self.assertEqual(base_find.point_2d.ewkt, "SRID=4326;POINT (42 3)")
self.assertEqual(base_find.point_source, "P")
+ def test_get_geo_items(self):
+ profile = get_current_profile()
+ profile.mapping = True
+ profile.save()
+
+ find = self.finds[0]
+ base_find = find.base_finds.all()[0]
+ srs, __ = SpatialReferenceSystem.objects.get_or_create(
+ txt_idx="wgs84",
+ defaults={"srid": 4326, "label": "WGS84", "auth_name": "EPSG"},
+ )
+
+ base_find = models.BaseFind.objects.get(pk=base_find.pk)
+
+ limit = (
+ "MULTIPOLYGON(((1 1,5 1,5 5,1 5,1 1),(2 2,2 3,3 3,3 2,2 2)),"
+ "((6 3,9 2,9 4,6 3)))"
+ )
+ base_find.multi_polygon = "SRID=4326;" + limit
+ base_find.point_source = None
+ base_find.point_2d = None
+ base_find.point = None
+ base_find.save()
+
+ base_find = models.BaseFind.objects.get(pk=base_find.pk)
+ dictPoly = {"externalPolygon1": [(1.0,1.0), (5.0,1.0), (5.0,5.0), (1.0,5.0), (1.0,1.0)],
+ "internalPolygon1": [(2.0,2.0), (2.0,3.0), (3.0,3.0), (3.0,2.0), (2.0,2.0)],
+ "externalPolygon2": [(6.0,3.0), (9.0,2.0), (9.0,4.0), (6.0,3.0)]}
+ resPoly = base_find.get_geo_items(get_polygons=True)
+ self.assertEqual(dictPoly, resPoly)
+ dictCentroid = {"centroid": (3.86111, 3.02778)}
+ resCentroid = base_find.get_geo_items(get_polygons=False)
+ self.assertEqual(dictCentroid, resCentroid)
class AutocompleteTest(AutocompleteTestBase, TestCase):
fixtures = FIND_FIXTURES