<coord2_tag_name>lon</coord2_tag_name> </exampleshape1> <exampleshape2>50.5735874 9.9972383; 50.574689 10.006046; 50.564493 10.008982; <coord1_tag_name>lat</coord1_tag_name> <coord2_tag_name>lon</coord2_tag_name> </exampleshape2> </shapes>'; ////<coord1_tag_name>lat</coord1_tag_name> ////<coord2_tag_name>lon</coord2_tag_name> // // search_req.setShape(cps.CircleDefinition("exampleshape1", [48.060736, -2.6902734], '1 km', 'lat', 'lon')); ////search_req.setShape([cps.CircleDefinition("exampleshape1", [48.060736, -2.6902734], '1 km', 'lat', 'lon'), cps.CircleDefinition("exampleshape2", [50.5735874, 9.9972383], '1 km', 'lat', 'lon')]); ////search_req.setShape(cps.CircleDefinition("exampleshape2", [50.5735874, 9.9972383], '1 km', 'lat', 'lon')); // search_req.setShape(cps.PolygonDefinition("exampleshape2", [[50.5735874, 9.9972383], [50.574689, 10.006046],[50.564493, 10.008982]], 'lat', 'lon')); // $searchRequest->setExtraXmlParam($shapes); $searchRequest->setShape($shape1, false); $searchRequest->setShape($shape2, false); // $searchRequest->setShape(array($shape1, $shape2)); $searchResponse = $cpsConnection->sendRequest($searchRequest); if ($searchResponse->getHits() > 0) { // getHits returns the total number of documents in the storage that match the query echo 'Found ' . $searchResponse->getHits() . ' documents<br />'; echo 'showing from ' . $searchResponse->getFrom() . ' to ' . $searchResponse->getTo() . '<br />'; foreach ($searchResponse->getDocuments() as $id => $document) { echo $document->lat . ' ' . $document->lon . "<br />\n\n "; } } else { echo 'Nothing found.'; } } catch (CPS_Exception $e) { var_dump($e->errors());
$query_without_amenities = $query; $aggregate = 'DISTINCT tags.amenity'; // aggregate distinct values of amenity tag if (count($amenities)) { if (array_search('-', $amenities) !== false) { // if there is amenity with value "-", this means that "Amenity is not set" was selected // lets replace - with ="" which tells Clusterpoint to look for documents for which this tag does not exist $amenities[array_search('-', $amenities)] = '=""'; } // add amenities filter to search request $query .= CPS_Term('{ ' . implode(' ', $amenities) . ' }', 'tags/amenity'); } $search_request = new CPS_SearchRequest($query, $offset, $docs); $search_request->setParam('list', '<document>yes</document>'); // search should return full documents $search_request->setShape($circle); // attach previously defined circle definition if ($query_without_amenities == $query) { // if there was no amenities filter, we can aggregate data together with search request $search_request->setAggregate($aggregate); } $search_response = $cps_connection->sendRequest($search_request); if ($search_response->getHits() > 0) { $objects['total'] = $search_response->getHits(); $objects['from'] = $search_response->getFrom() + 1; // getFrom() returns offset. We want to show offset +1 $objects['to'] = $search_response->getTo(); $objects['pages'] = ceil($objects['total'] / $docs); $objects['current_page'] = $search_response->getFrom() / $docs + 1; foreach ($search_response->getDocuments(DOC_TYPE_ARRAY) as $id => $document) { ksort($document['tags']);