Skip to content
Snippets Groups Projects
Commit 54ce263d authored by Benoist FONTAINE's avatar Benoist FONTAINE
Browse files

Correction cadrage objet du visualiseur

parent c314a315
No related branches found
No related tags found
No related merge requests found
Pipeline #15940 failed
......@@ -14,6 +14,7 @@ Trait ContextTrait
public function getServicePath($account){
$serviceFile = $this->config->params->PATH_DATA . "SYSTEM/services.xml";
$doc = new \DOMDocument();
if (@$doc->load($serviceFile)){
......@@ -63,12 +64,11 @@ Trait ContextTrait
$contextFolder = $this->config->params->PATH_DATA . "/owscontext/" . $account . '/';
$contextFilename = str_replace('.map', '.geojson', $contextPath);
}
if (file_exists($contextFolder . $contextFilename)) {
$fileContent = file_get_contents($contextFolder . $contextFilename);
$fileContentAsJson = json_decode($fileContent, true);
$mapName = $fileContentAsJson["id"];
//$mapName = ltrim($contextPath, "/");
......@@ -111,6 +111,16 @@ Trait ContextTrait
$queryExtent = $this->getObjectExtent($object, $fileContentAsJson, $accountPath, $account);
if($queryExtent && is_array($queryExtent)){
//ajout d'une tolérance pour les objets ponctuels
//TODO :gérer le 4326
if($queryExtent[0]["minx"]==$queryExtent[0]["maxx"]){
$queryExtent[0]["minx"] = $queryExtent[0]["minx"]-100;
$queryExtent[0]["maxx"] = $queryExtent[0]["maxx"]+100;
}
if($queryExtent[0]["miny"]==$queryExtent[0]["maxy"]){
$queryExtent[0]["miny"] = $queryExtent[0]["miny"]-100;
$queryExtent[0]["maxy"] = $queryExtent[0]["maxy"]+100;
}
$fileContentAsJson["properties"]["bbox"][0] = (float) $queryExtent[0]["minx"];
$fileContentAsJson["properties"]["bbox"][1] = (float) $queryExtent[0]["miny"];
$fileContentAsJson["properties"]["bbox"][2] = (float) $queryExtent[0]["maxx"];
......@@ -196,7 +206,9 @@ Trait ContextTrait
if(count($properties)!==3){
throw new \Exception("invalid number of object arguments");
}
$layerName = $properties[0];
$layerTitle = $properties[0];
$layerName = $this->getLayerName($layerTitle, $contextJson["properties"]["extension"]["layers"]);
$key = $properties[1];
$value = $properties[2];
......@@ -396,4 +408,31 @@ Trait ContextTrait
}
return $rootLayer;
}
/**
* Search layerName according to title or identifier
* @param layerTitle : title or identifier
* @param contextLayers : context obj
* return layerName in mapfile
*/
protected function getLayerName($layerTitle, $contextLayers){
if (array_key_exists('class', $contextLayers) && strcmp($contextLayers["class"], "LayerGroup") !== 0) {
//TODO add test on identifier, but not present yet in context
if (array_key_exists('extension', $contextLayers) &&
array_key_exists('name', $contextLayers["extension"])
&& strcmp($contextLayers["extension"]["name"],$layerTitle)===0) {
return $contextLayers["extension"]["layerName"];
}
}else{
//pour les groupes, parcours du tableau de layers
foreach ($contextLayers["layers"] as $key => $contextLayer){
$layerName = $this->getLayerName($layerTitle, $contextLayer);
if($layerName!=null){
return $layerName;
}
}
}
return null;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment