terriajs icon indicating copy to clipboard operation
terriajs copied to clipboard

Pelias searchProvider

Open irbian opened this issue 7 months ago • 0 comments

Following this comment https://github.com/TerriaJS/terriajs/issues/5107#issuecomment-2150610334

We implemented a Pelias one based on the CesiumIon one. We just handled that we could have either of bbox or center point:

searchResults.results = response.features.map<SearchResult>((feature) => {
       
        let [longitude, latitude] = feature.geometry.coordinates;
        const MARGIN = 0.001;
        const [w, s, e, n] = feature.bbox ? feature.bbox : [longitude - MARGIN, latitude - MARGIN, longitude + MARGIN, latitude + MARGIN];
        [longitude, latitude] = feature.geometry.coordinates ? feature.geometry.coordinates : [(s + n) / 2, (e + w) / 2];
        const rectangle = Rectangle.fromDegrees(w, s, e, n);

        return new SearchResult({
          name: feature.properties.label,
          clickAction: createZoomToFunction(this, rectangle),
          location: {
            latitude: latitude,
            longitude: longitude
          }
        });
      });

We probably would need yet to handle that margin to wrap around and that it changes the norther we are, but it would be a start

This could be used to generalize CesiumIonSearch into a PeliasSearch one that by default points to Cesium, but we are interested on keeping two different geocoders and our tests didn't allow the same SearchProvider with different configs

irbian avatar Jun 13 '25 15:06 irbian