From 0b954a0061e8d0ed2475e59aa129e66e27d8ded9 Mon Sep 17 00:00:00 2001 From: jjrom Date: Thu, 20 Apr 2023 11:36:13 +0200 Subject: [PATCH 1/6] * Support both input datetime and start_datetime/end_datetime * Return datetime for single date feature or start_datetime/end_datetime for range feature but not both --- app/resto/core/RestoModel.php | 8 ++++++++ app/resto/core/utils/RestoFeatureUtil.php | 15 +++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/resto/core/RestoModel.php b/app/resto/core/RestoModel.php index afb82769..890bb5dd 100755 --- a/app/resto/core/RestoModel.php +++ b/app/resto/core/RestoModel.php @@ -894,6 +894,14 @@ private function prepareFeatureArray($collection, $data, $params = array()) } unset($properties['datetime']); } + if (isset($properties['start_datetime'])) { + $properties['startDate'] = $dates[0]; + unset($properties['start_datetime']); + } + if (isset($properties['end_datetime'])) { + $properties['completionDate'] = $dates[0]; + unset($properties['end_datetime']); + } /* * Add collection to $properties to initialize facet counts on collection diff --git a/app/resto/core/utils/RestoFeatureUtil.php b/app/resto/core/utils/RestoFeatureUtil.php index acb47ba7..6f0ec08c 100755 --- a/app/resto/core/utils/RestoFeatureUtil.php +++ b/app/resto/core/utils/RestoFeatureUtil.php @@ -174,16 +174,19 @@ private function formatRawFeatureArray($rawFeatureArray, $collection) switch ($key) { case 'collection': + break; + case 'completionDate': + $featureArray['properties']['end_datetime'] = $rawFeatureArray[$key]; break; case 'startDate': - /* [STAC][1.0.0] datetime is no more a range - $featureArray['properties']['datetime'] = $rawFeatureArray[$key] . (isset($rawFeatureArray['completionDate']) ? '/' . $rawFeatureArray['completionDate'] : ''); - */ - $featureArray['properties']['datetime'] = $rawFeatureArray[$key]; - $featureArray['properties']['start_datetime'] = $rawFeatureArray[$key]; - $featureArray['properties']['end_datetime'] = $rawFeatureArray['completionDate'] ?? $rawFeatureArray[$key]; + if (isset($rawFeatureArray['completionDate'])) { + $featureArray['properties']['start_datetime'] = $rawFeatureArray[$key]; + } + else { + $featureArray['properties']['datetime'] = $rawFeatureArray[$key]; + } break; case 'assets': From e51fe321f1885a55e75a5b2b9976980c36148027 Mon Sep 17 00:00:00 2001 From: jjrom Date: Thu, 20 Apr 2023 13:27:08 +0200 Subject: [PATCH 2/6] Don't tag for year/month/day for ranges --- app/resto/core/addons/Tag.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/resto/core/addons/Tag.php b/app/resto/core/addons/Tag.php index 69f3dfa9..9eb0cf3c 100644 --- a/app/resto/core/addons/Tag.php +++ b/app/resto/core/addons/Tag.php @@ -382,27 +382,30 @@ private function keywordsFromFacets($properties, $facetCategory, $model) */ private function getDateKeywords($properties, $model) { + + $startDate = $properties[$model->searchFilters['time:start']['key']]; + /* - * startDate property is not present + * No startDate property or both startDate and completionDate are presents => range is not supported */ - if (! isset($properties[$model->searchFilters['time:start']['key']])) { + if (! isset($startDate) || (isset($startDate) && isset($properties['completionDate']))) { return array(); } /* * Year */ - $year = substr($properties[$model->searchFilters['time:start']['key']], 0, 4); + $year = substr($startDate, 0, 4); /* * Month */ - $month = substr($properties[$model->searchFilters['time:start']['key']], 5, 2); + $month = substr($startDate, 5, 2); /* * Day */ - $day = substr($properties[$model->searchFilters['time:start']['key']], 8, 2); + $day = substr($startDate, 8, 2); return array( array( From db7a89bedb7834761cd7cdcd69ab35136401067e Mon Sep 17 00:00:00 2001 From: jjrom Date: Sat, 22 Apr 2023 17:27:18 +0200 Subject: [PATCH 3/6] Update version to 7.0.1 --- app/resto/core/RestoConstants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/resto/core/RestoConstants.php b/app/resto/core/RestoConstants.php index d98f8f25..7205d266 100644 --- a/app/resto/core/RestoConstants.php +++ b/app/resto/core/RestoConstants.php @@ -20,7 +20,7 @@ class RestoConstants // [IMPORTANT] Starting resto 7.x, default routes are defined in RestoRouter class // resto version - const VERSION = '7.0.0'; + const VERSION = '7.0.1'; /* ============================================================ * NEVER EVER TOUCH THESE VALUES From 42fcd7694c1d8299dadbe48c16a9d633bcb82cc1 Mon Sep 17 00:00:00 2001 From: jjrom Date: Mon, 24 Apr 2023 09:13:28 +0200 Subject: [PATCH 4/6] Huge typo in start_datetime/end_datetime --- app/resto/core/RestoModel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/resto/core/RestoModel.php b/app/resto/core/RestoModel.php index 890bb5dd..0944755c 100755 --- a/app/resto/core/RestoModel.php +++ b/app/resto/core/RestoModel.php @@ -895,11 +895,11 @@ private function prepareFeatureArray($collection, $data, $params = array()) unset($properties['datetime']); } if (isset($properties['start_datetime'])) { - $properties['startDate'] = $dates[0]; + $properties['startDate'] = $properties['start_datetime']; unset($properties['start_datetime']); } if (isset($properties['end_datetime'])) { - $properties['completionDate'] = $dates[0]; + $properties['completionDate'] = $properties['end_datetime']; unset($properties['end_datetime']); } From e00efff81d8ded7c290161ad702899718d6f3b2f Mon Sep 17 00:00:00 2001 From: jjrom Date: Mon, 24 Apr 2023 12:04:14 +0200 Subject: [PATCH 5/6] * Add SPLIT_GEOMETRY_ON_DATELINE configuration to enable/disable input geometry split on -180/180 * Allow update of geometry in updateFeature --- app/resto/core/RestoContext.php | 3 +++ app/resto/core/api/CollectionsAPI.php | 4 ++-- app/resto/core/api/FeaturesAPI.php | 4 ++-- app/resto/core/dbfunctions/FeaturesFunctions.php | 6 ++++-- build/resto/config.php.template | 1 + config.env | 4 ++++ 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/resto/core/RestoContext.php b/app/resto/core/RestoContext.php index 3e66e890..a2c8f674 100755 --- a/app/resto/core/RestoContext.php +++ b/app/resto/core/RestoContext.php @@ -84,6 +84,9 @@ class RestoContext // True to automatically validate user on activation 'userAutoActivation' => false, + // True to split geometries that cross the -180/180 dateline + 'splitGeometryOnDateLine' => true, + // Sendmail configuration 'sendmail' => array( 'senderName' => 'admin', diff --git a/app/resto/core/api/CollectionsAPI.php b/app/resto/core/api/CollectionsAPI.php index 75d6b8a1..6a9697d1 100755 --- a/app/resto/core/api/CollectionsAPI.php +++ b/app/resto/core/api/CollectionsAPI.php @@ -576,7 +576,7 @@ public function deleteCollection($params) * in="query", * style="form", * required=false, - * description="Set to false to not split geometry during feature insertion. Default is true", + * description="Superseed the SPLIT_GEOMETRY_ON_DATELINE configuration i.e. set to true to split geometry during feature insertion - false otherwise. Default is set to SPLIT_GEOMETRY_ON_DATELINE", * @OA\Schema( * type="boolean" * ) @@ -685,7 +685,7 @@ public function insertFeatures($params, $body) * Insert feature(s) within database */ $result = $collection->addFeatures($body, array( - '_splitGeom' => isset($params['_splitGeom']) && filter_var($params['_splitGeom'], FILTER_VALIDATE_BOOLEAN) === false ? false : true, + '_splitGeom' => isset($params['_splitGeom']) && filter_var($params['_splitGeom'], FILTER_VALIDATE_BOOLEAN) === false ? false : $this->context->core["splitGeometryOnDateLine"], 'tolerance' => isset($params['tolerance']) && is_numeric($params['tolerance']) ? (float) $params['tolerance'] : null, 'maxpoints' => isset($params['maxpoints']) && ctype_digit($params['maxpoints']) ? (integer) $params['maxpoints'] : null )); diff --git a/app/resto/core/api/FeaturesAPI.php b/app/resto/core/api/FeaturesAPI.php index 9c420112..462db4dd 100755 --- a/app/resto/core/api/FeaturesAPI.php +++ b/app/resto/core/api/FeaturesAPI.php @@ -699,8 +699,8 @@ public function updateFeature($params, $body) } // Specifically set splitGeometry - $params['_splitGeom'] = isset($params['_splitGeom']) && filter_var($params['_splitGeom'], FILTER_VALIDATE_BOOLEAN) === false ? false : true; - + $params['_splitGeom'] = isset($params['_splitGeom']) && filter_var($params['_splitGeom'], FILTER_VALIDATE_BOOLEAN) === false ? false : $this->context->core["splitGeometryOnDateLine"]; + return $collection->model->updateFeature($feature, $collection, $body, $params); } diff --git a/app/resto/core/dbfunctions/FeaturesFunctions.php b/app/resto/core/dbfunctions/FeaturesFunctions.php index 4488f2c8..7d725306 100755 --- a/app/resto/core/dbfunctions/FeaturesFunctions.php +++ b/app/resto/core/dbfunctions/FeaturesFunctions.php @@ -427,7 +427,10 @@ public function updateFeature($feature, $collection, $newFeatureArray) /*'likes' => $oldFeatureArray['properties']['likes'], 'comments' => $oldFeatureArray['properties']['comments'],*/ 'metadata' => array(), - 'updated' => isset($newFeatureArray['properties']) && isset($newFeatureArray['properties']['updated']) ? $newFeatureArray['properties']['updated'] : 'now()' + 'updated' => isset($newFeatureArray['properties']) && isset($newFeatureArray['properties']['updated']) ? $newFeatureArray['properties']['updated'] : 'now()', + 'geometry' => $newFeatureArray['topologyAnalysis']['geometry'] ?? null, + 'centroid' => $newFeatureArray['topologyAnalysis']['centroid'] ?? null, + 'geom' => $newFeatureArray['topologyAnalysis']['geom'] ?? null ), array( 'title', @@ -437,7 +440,6 @@ public function updateFeature($feature, $collection, $newFeatureArray) ) ); - try { /* * Begin transaction diff --git a/build/resto/config.php.template b/build/resto/config.php.template index 7d240f57..64ee848d 100755 --- a/build/resto/config.php.template +++ b/build/resto/config.php.template @@ -16,6 +16,7 @@ return array( 'tokenDuration' => ${JWT_DURATION:-8640000}, 'userAutoValidation' => ${USER_AUTOVALIDATION:-true}, 'userAutoActivation' => ${USER_AUTOACTIVATION:-true}, + 'splitGeometryOnDateLine' => ${SPLIT_GEOMETRY_ON_DATELINE:-true}, 'useCache' => ${USE_CACHE:-false}, 'corsWhiteList' => array(${CORS_WHITELIST}), 'htmlSearchEndpoint' => '${SEARCH_OPENSEARCH_HTML_ENDPOINT}', diff --git a/config.env b/config.env index 0f5ea081..418a4223 100644 --- a/config.env +++ b/config.env @@ -68,6 +68,10 @@ DATABASE_USER_PASSWORD=resto ### True to use geometry_part table instead of feature to compute geometrical intersection #USE_GEOMETRY_PART=false +### True to split input geometries that crosses -180/180 +### [IMPORTANT] Set to false for geometries larger than half the earth globe - typically global product for instance +#SPLIT_GEOMETRY_ON_DATELINE=true + ### ===================================================================== ### Security configuration ### ===================================================================== From 7a0c7e6a032ab7930159345f40225be7c2e2fdbd Mon Sep 17 00:00:00 2001 From: jjrom Date: Tue, 25 Apr 2023 14:09:49 +0200 Subject: [PATCH 6/6] Facet of type "catalog" are always linked to '*' collections --- app/resto/core/dbfunctions/FacetsFunctions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/resto/core/dbfunctions/FacetsFunctions.php b/app/resto/core/dbfunctions/FacetsFunctions.php index f0815ded..20b2a7d0 100755 --- a/app/resto/core/dbfunctions/FacetsFunctions.php +++ b/app/resto/core/dbfunctions/FacetsFunctions.php @@ -218,7 +218,8 @@ public function getFacetsFromKeywords($keywords, $facetCategories, $collectionId 'parentId' => $keywords[$i]['parentId'] ?? 'root', 'value' => $keywords[$i]['name'] ?? null, 'type' => $keywords[$i]['type'], - 'collection' => $collectionId, + // [IMPORTANT] catalog facet are always attached to all collections + 'collection' => $keywords[$i]['type'] === 'catalog' ? '*' : $collectionId, 'isLeaf' => $facetCategory['isLeaf'] ); }