Skip to content

Commit 7fd76e1

Browse files
committed
Issue in storeCatalogs
1 parent 21e3bcb commit 7fd76e1

File tree

5 files changed

+76
-4
lines changed

5 files changed

+76
-4
lines changed

app/resto/core/RestoConstants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RestoConstants
2020
// [IMPORTANT] Starting resto 7.x, default routes are defined in RestoRouter class
2121

2222
// resto version
23-
const VERSION = '9.0.0-RC3';
23+
const VERSION = '9.0.0-RC4';
2424

2525
/* ============================================================
2626
* NEVER EVER TOUCH THESE VALUES

app/resto/core/addons/Cataloger.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ private function processITagKeywords($iTagFeature)
206206
}
207207
break;
208208

209+
case 'physical':
210+
$catalogs[] = array(
211+
'id' => 'physical',
212+
'title' => 'Physical',
213+
'description' => 'Automatic physical classification processed by [iTag](https://github.com/jjrom/itag)'
214+
);
215+
$catalogs = array_merge($catalogs, $this->getCatalogsFromPhysical($value, 'physical'));
216+
break;
217+
209218
case 'landcover':
210219
$catalogs[] = array(
211220
'id' => 'landcover',
@@ -314,6 +323,37 @@ private function getCatalogsFromLandCover($properties, $parentId)
314323
return $catalogs;
315324
}
316325

326+
/**
327+
* Get physical catalogs
328+
*
329+
* @param array $physicals
330+
* @param string $parentId
331+
*/
332+
private function getCatalogsFromPhysical($physicals, $parentId)
333+
{
334+
$catalogs = array();
335+
336+
/*
337+
* Main landcover
338+
*/
339+
for ($i = 0, $ii=count($physicals); $i < $ii; $i++) {
340+
$exploded = explode(RestoConstants::TAG_SEPARATOR, $physicals[$i]['id']);
341+
$type = $exploded[0];
342+
$id = $parentId . '/' . $type . 's';
343+
if ( !$this->alreadyExists($catalogs, $type) ) {
344+
$catalogs[] = array(
345+
'id' => $id,
346+
'title' => ucfirst($type) . 's',
347+
'description' => 'Automatic ' . $type . ' classification processed by [iTag](https://github.com/jjrom/itag)',
348+
'rtype' => $type
349+
);
350+
}
351+
$catalogs[] = $this->getCatalogFromGeneric($physicals[$i], $id);
352+
}
353+
354+
return $catalogs;
355+
}
356+
317357
/**
318358
* Get generic keywords
319359
*
@@ -365,6 +405,7 @@ private function getCatalogFromGeneric($property, $parentId)
365405
$catalog = array(
366406
'id' => (isset($parentId) ? $parentId : '') . '/' . $exploded[1],
367407
'title' => $property['name'] ?? $exploded[1],
408+
'description' => 'Catalog of features for ' . ($property['name'] ?? $exploded[1]),
368409
'rtype' => $exploded[0],
369410
'hashtag' => $property['id']
370411
);

app/resto/core/dbfunctions/CatalogsFunctions.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,10 @@ public function storeCatalog($catalog, $userid, $baseUrl, $collectionId, $featur
282282
*
283283
* @param array $catalogs
284284
* @param string $userid
285-
* @param string $baseUrl
286285
* @param RestoCollection $collection
287286
* @param string $featureId
288287
*/
289-
public function storeCatalogs($catalogs, $userid, $baseUrl, $collection, $featureId)
288+
public function storeCatalogs($catalogs, $userid, $collection, $featureId)
290289
{
291290
// Empty catalogs - do nothing
292291
if (!isset($catalogs) || count($catalogs) === 0) {
@@ -300,7 +299,7 @@ public function storeCatalogs($catalogs, $userid, $baseUrl, $collection, $featur
300299
$baseUrl = $collection->context->core['baseUrl'];
301300
}
302301
for ($i = count($catalogs); $i--;) {
303-
$this->storeCatalog($catalog, $userid, $baseUrl, $collectionId, $featureId);
302+
$this->storeCatalog($catalogs[$i], $userid, $baseUrl, $collectionId, $featureId);
304303
}
305304

306305
return $catalogs;

docs/COLLECTIONS_AND_CATALOGS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Then get the feature :
4040

4141
*Note: Any user with the "createFeature" right can insert a feature to a collection he owns ([see rights](./USERS.md))*
4242

43+
curl -X POST -d@examples/features/dummySargasse.json "http://admin:admin@localhost:5252/collections/S2/items"
44+
4345
## Catalogs
4446

4547
### Create a catalog
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"id": "DummySargasse",
3+
"type": "Feature",
4+
"properties": {
5+
"datetime": "2024-06-21T16:27:00Z"
6+
},
7+
"geometry": {
8+
"coordinates": [
9+
[
10+
[
11+
-64.8,
12+
32.3
13+
],
14+
[
15+
-65.5,
16+
18.3
17+
],
18+
[
19+
-80.3,
20+
25.2
21+
],
22+
[
23+
-64.8,
24+
32.3
25+
]
26+
]
27+
],
28+
"type": "Polygon"
29+
}
30+
}

0 commit comments

Comments
 (0)