diff --git a/module/javascript/app/vmap/tools/insert.js b/module/javascript/app/vmap/tools/insert.js index 6e01c71fad23a4a0c796cc4cafe41ee526e0c131..afc68e8ec5e645239de0b70f5fa4168240dd88da 100644 --- a/module/javascript/app/vmap/tools/insert.js +++ b/module/javascript/app/vmap/tools/insert.js @@ -258,6 +258,11 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController = function ($scope, */ $scope['aQueryableBOs'] = oVmap.getMapManager().getQueryableBusinessObjectsAsArray(true); + /** + * Business objects avaliable for avoiding intersections + */ + $scope['aAvoidIntersectionsBOs'] = []; + /** * Object to insert * oInsertObject.sFormDefinitionName name of the form (insert, upload, display) @@ -367,8 +372,10 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController = function ($scope, // Au changement d'objet métier en cours d'insertion this.$scope_.$watch('selectedBoId', function () { - this_.updateInsertForm(); - this_.selectCurrentBoForSnapping(); + this_.updateInsertForm(null, function(){ + this_.selectCurrentBoForSnapping(); + this_.loadAvoidIntersectionBos(); + }); }); // Affiche les modales en plein écran pour la version mobile @@ -412,6 +419,7 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.loadInsert }); this.checkEditionScale(); + this.loadAvoidIntersectionBos(); }; /** @@ -434,6 +442,40 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.selectCurr this.checkEditionScale(); }; + +/** + * Load this.aAvoidIntersectionsBOs + * + */ +nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.loadAvoidIntersectionBos = function () { + oVmap.log('nsVmap.nsToolsManager.Insert.inserttoolController.loadAvoidIntersectionBos'); + + var this_ = this; + + // Types de géométries pour le calcul des jointures + var aActiveGeomTypes = ['POLYGON', 'MULTIPOLYGON', 'GEOMETRY', 'GEOMETRYCOLLECTION']; + + // Objets métiers actifs pour la calcul des jointures + this.$scope_['aAvoidIntersectionsBOs'] = []; + + if (goog.isDefAndNotNull(this.$scope_['oInsertObject']['sGeomType'])) { + + // Si la couche en cours d'insertion est dans aActiveGeomTypes + if (aActiveGeomTypes.indexOf(this.$scope_['oInsertObject']['sGeomType']) !== -1) { + for (var i = 0; i < this_.$scope_['aQueryableBOs'].length; i++) { + + // Si la couche cible est dans aActiveGeomTypes + if (goog.isDefAndNotNull(this_.$scope_['aQueryableBOs'][i]['bo_geom_type'])) { + if(aActiveGeomTypes.indexOf(this_.$scope_['aQueryableBOs'][i]['bo_geom_type']) !== -1){ + + this.$scope_['aAvoidIntersectionsBOs'].push(this_.$scope_['aQueryableBOs'][i]); + } + } + } + } + } +} + /** * Vérifie que l'échelle en cours respecte les spécification de l'objet métier */ @@ -1144,7 +1186,6 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.updateCirc return feature; }; - /** * Edit the given feature to avoid intersections with layers defined in snapOptions.avoidIntersections * @param {ol.Feature} olFeature @@ -1167,6 +1208,13 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.avoidInter } } +/** + * Modify the feature geometry to avoid intersections with BOs in aIntersectionBos + * + * @param {string} aIntersectionBos + * @param {ol.Feature} olFeature + * @param {object|undefines} opt_options + */ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.setDiffGeom_ = function (aIntersectionBos, olFeature, opt_options) { oVmap.log('nsVmap.nsToolsManager.Insert.inserttoolController.setDiffGeom_'); @@ -1201,6 +1249,13 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.setDiffGeo } +/** + * Get the diff intersection geometry + * + * @param {string} sBoId + * @param {string} sEWKTGeom + * @return {promise} + */ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.getDiffGeom_ = function (sBoId, sEWKTGeom) { oVmap.log('nsVmap.nsToolsManager.Insert.inserttoolController.getDiffGeom_'); diff --git a/module/template/tools/insert.html b/module/template/tools/insert.html index f10c71ac0081e963307028e10294191d20ffac79..a8937a7c680ceb14147b2c7fe1d108a1921340cd 100644 --- a/module/template/tools/insert.html +++ b/module/template/tools/insert.html @@ -285,8 +285,7 @@ </div> </div> <div class="row" - ng-repeat="bo in aQueryableBOs" - ng-if="bo.bo_geom_type === 'POLYGON' || bo.bo_geom_type === 'MULTIPOLYGON' || bo.bo_geom_type === 'GEOMETRYCOLLECTION' || bo.bo_geom_type === 'GEOMETRY'"> + ng-repeat="bo in aAvoidIntersectionsBOs"> <div class="col-sm-5 text-right"> <label>{{bo.bo_title}}</label> </div>