diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/static/js/ishtar-map.js | 59 | ||||
-rw-r--r-- | ishtar_common/tests.py | 24 |
2 files changed, 45 insertions, 38 deletions
diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js index 4d6ebcd48..00aadfd9b 100644 --- a/ishtar_common/static/js/ishtar-map.js +++ b/ishtar_common/static/js/ishtar-map.js @@ -684,31 +684,23 @@ var display_geo_items = function(map_id, base_url, slug, pk, if (httpRequest.readyState === XMLHttpRequest.DONE) { if (httpRequest.status === 200) { geo_items = to_geo_items(JSON.parse(httpRequest.responseText), slug, disp_cr, disp_bf) + console.log('geoitems') + console.log(geo_items) if (current_test) { geo_items_features[map_id] = []; } - var feat = null; - for (geo_item of geo_items['base-finds']) { - if (get_poly) { - feat = display_associated_polys(map_id, geo_item, 'basefind'); - } else { - feat = display_associated_points(map_id, geo_item, 'basefind'); - } - if (current_test) { - geo_items_features[map_id].push(feat); - } - } - for (geo_item of geo_items['context-records']) { - if (get_poly) { - feat = display_associated_polys(map_id, geo_item, 'contextrecord'); - } else { - feat = display_associated_points(map_id, geo_item, 'contextrecord'); - } - if (current_test) { - geo_items_features[map_id].push(feat); - } + let bfs = null; + let crs = null; + if (get_poly) { + bfs = display_associated_polys(map_id, geo_items['base-finds'], 'basefind'); + crs = display_associated_polys(map_id, geo_items['context-records'], 'contextrecord'); + } else { + bfs = display_associated_points(map_id, geo_items['base-finds'], 'basefind'); + crs = display_associated_points(map_id, geo_items['context-records'], 'contextrecord'); } if (current_test) { + geo_items_features[map_id].push(bfs) + geo_items_features[map_id].push(crs) $("#http-geo-items-ready").show(); } } else { return; } @@ -719,21 +711,26 @@ var display_geo_items = function(map_id, base_url, slug, pk, }; var to_geo_items = function (obj, slug, disp_cr, disp_bf) { - const objects = {'context-records': [], 'base-finds': []}; + const objects = {'context-records': {'features': [], 'type': 'FeatureCollection'}, + 'base-finds': {'features': [], 'type': 'FeatureCollection'}}; if (slug === "operation") { const crs = obj['properties']['context-records']; for (const cr of crs['features']) { - if (disp_bf) { - objects['base-finds'].push(cr['properties']['base-finds']) + if (disp_bf) {console.log(cr); + for (const bf of cr['properties']['base-finds']['features']) { + objects['base-finds']['features'].push(bf) + } } delete cr['properties']; - } - if (disp_cr) { - objects['context-records'].push(crs); + if (disp_cr) { + objects['context-records']['features'].push(cr) + } } } else { - objects['base-finds'].push(obj['properties']['base-finds']) + for (const bf of obj['properties']['base-finds']['features']) { + objects['base-finds']['features'].push(bf) + } } return objects; } @@ -780,9 +777,9 @@ var get_associated_context_record_style = function (feature) { }; var display_associated_points = function (map_id, points, slug) { - //console.log('geo items points') - //console.log(points); - /*_point_features = geojson_format.readFeatures(points); + console.log('geo items points') + console.log(points); + _point_features = geojson_format.readFeatures(points); _cluster_source = new ol.source.Cluster({ distance: 40, source: new ol.source.Vector() @@ -799,7 +796,7 @@ var display_associated_points = function (map_id, points, slug) { style: style }); map[map_id].addLayer(_cluster_layer); - return _point_features;*/ + return _point_features; } // for test purpose diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 1ab718590..33a7bf2dc 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -3137,7 +3137,6 @@ class SeleniumTests(StaticLiveServerTestCase): from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC - from archaeological_operations.models import Operation @classmethod def setUpClass(cls): @@ -3177,10 +3176,20 @@ class SeleniumTests(StaticLiveServerTestCase): ope1 = create_operation(self.user) ope2 = create_operation(self.user) - GeomaticFindsTest.create_cr_with_bfs(ope1, "Point", "Point", ["Polygon", "Point"], "CR Pt Poly Pt") - GeomaticFindsTest.create_cr_with_bfs(ope1, "Point", "Polygon", ["Polygon", "Point"], "CR Poly Poly Pt") - GeomaticFindsTest.create_cr_with_bfs(ope2, "Polygon", "Point", ["Polygon", "Point"], "CR Pt Poly Pt") - GeomaticFindsTest.create_cr_with_bfs(ope2, "Polygon", "Polygon", ["Polygon", "Point"], "CR Poly Poly Pt") + pks = {'ope': {'Pt': ope1.pk, 'Poly': ope2.pk}, 'cr': {}, 'bf': {}} + + def merge_pks(dic1, dic2): + for key in dic2.keys(): + for label in dic2[key]: + dic1[key][label] = dic2[key][label] + + merge_pks(pks, GeomaticFindsTest.create_cr_with_bfs(ope1, "Point", "Point", ["Polygon", "Point"], "CR Pt Pt")) + merge_pks(pks, GeomaticFindsTest.create_cr_with_bfs(ope1, "Point", "Polygon", ["Polygon", "Point"], "CR Pt Poly")) + merge_pks(pks, GeomaticFindsTest.create_cr_with_bfs(ope2, "Polygon", "Point", ["Polygon", "Point"], "CR Poly Pt")) + merge_pks(pks, GeomaticFindsTest.create_cr_with_bfs(ope2, "Polygon", "Polygon", ["Polygon", "Point"], "CR Poly Poly")) + + print('PKS AAAAAAAAAAAAAAAAA') + print(pks) geom_ope = [ [[[[1, 1], [5, 1], [5, 5], [1, 5], [1, 1]], [[2, 2], [2, 3], [3, 3], [3, 2], [2, 2]]], @@ -3191,7 +3200,7 @@ class SeleniumTests(StaticLiveServerTestCase): geom_cr = [ [[[[2, 1], [5, 1], [5, 5], [1, 5], [2, 1]], [[2, 2], [2, 3], [3, 3], [3, 2], [2, 2]]], [[[6, 3], [9, 2], [9, 4], [6, 3]]]], - [3.86111, 3.02778], #TODO: change it + [4.17708, 3.11458], [3.9, 3] ] geom_bf = [ @@ -3200,7 +3209,8 @@ class SeleniumTests(StaticLiveServerTestCase): [4.42105, 2.73684], [3.9, 2.9] ] - return [geom_ope, geom_cr, geom_bf] + return [geom_ope, geom_cr, geom_bf], [ope1.pk, ope2.pk] + def scroll(self, element): self.selenium.execute_script( |