-
Notifications
You must be signed in to change notification settings - Fork 5
POLAR@3: Add nominatim support #606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oeninghe-dataport
wants to merge
11
commits into
next
Choose a base branch
from
vue3/add-nominatim-support
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9757271
feat: add nominatim support to addressSearch and reverseGeocoder
oeninghe-dataport 41544aa
Merge remote-tracking branch 'origin/next' into vue3/add-nominatim-su…
oeninghe-dataport b944581
docs: use non-question sentences for attribute typedoc
oeninghe-dataport 3221cd5
refactor(reverseGeocoder): simplify return object for nominatim
oeninghe-dataport 6a58368
chore: remove TODO and model idea as feature request
oeninghe-dataport 9cae6a1
refactor: replace functional implementation with simpler procedural
oeninghe-dataport 169d26e
refactor: introduce generic transform util for geometries
oeninghe-dataport d19d95a
refactor: type response of nominatim feature search
oeninghe-dataport 687b39c
test(snowbox): remove optional queryParameters for nominatim
oeninghe-dataport 4aed172
Merge branch 'next' into vue3/add-nominatim-support
oeninghe-dataport 5c87397
docs: fix typo for transformGeometry
oeninghe-dataport File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import type { GeoJSONFeatureCollection } from 'ol/format/GeoJSON' | ||
|
|
||
| import type { PolarGeoJsonFeatureCollection } from '@/core' | ||
|
|
||
| import type { NominatimParameters } from './types' | ||
|
|
||
| import { transformGeometry } from '../transformGeometry' | ||
|
|
||
| export default async function ( | ||
| signal: AbortSignal, | ||
| url: string, | ||
| inputValue: string, | ||
| queryParameters: NominatimParameters | ||
| ): Promise<PolarGeoJsonFeatureCollection> { | ||
| const { epsg, maxFeatures, ...native } = queryParameters | ||
|
|
||
| const fetchUrl = new URL(url) | ||
| for (const [key, value] of Object.entries(native)) { | ||
| fetchUrl.searchParams.set( | ||
| key, | ||
| Array.isArray(value) ? value.join(',') : String(value) | ||
| ) | ||
| } | ||
| if (maxFeatures) { | ||
| fetchUrl.searchParams.set('limit', String(maxFeatures)) | ||
| } | ||
| fetchUrl.searchParams.set('q', inputValue) | ||
| fetchUrl.searchParams.set('format', 'geojson') | ||
| // Setting this to 1 is currently not supported well by addressSearch plugin. The plugin expects a point geometry. | ||
| fetchUrl.searchParams.set('polygon_geojson', '0') | ||
| fetchUrl.searchParams.set('polygon_threshold', '5') | ||
|
|
||
| return await fetch(fetchUrl, { | ||
| signal, | ||
| }) | ||
| .then(async (response) => <GeoJSONFeatureCollection>await response.json()) | ||
| .then((featureCollection) => ({ | ||
| ...featureCollection, | ||
| features: featureCollection.features.map((feature) => ({ | ||
| ...feature, | ||
| title: feature.properties?.display_name, | ||
| geometry: transformGeometry(feature.geometry, 'EPSG:4326', epsg), | ||
| })), | ||
| })) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| import { toMerged } from 'es-toolkit' | ||
| import { GeoJSON, WFS } from 'ol/format' | ||
| import { transform as transformCoordinates } from 'ol/proj' | ||
|
|
||
| import type { PolarGeoJsonFeature, PolarGeoJsonFeatureCollection } from '@/core' | ||
|
|
||
| import { transformGeometry } from '@/lib/transformGeometry' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this be the correct import, if #750 is merged or will there be a relative path? Especially as a relative path is used in In this scenario, I prefer the way it is written in this file. |
||
|
|
||
| import { getFeatureTitleFromPattern } from './getFeatureTitleFromPattern' | ||
|
|
||
| const parser = new WFS() | ||
|
|
@@ -53,13 +53,11 @@ export async function parseWfsResponse( | |
| } | ||
| } | ||
| if (epsgCode) { | ||
| featureObject.geometry = toMerged(featureObject.geometry, { | ||
| coordinates: transformCoordinates( | ||
| featureObject.geometry.coordinates, | ||
| `EPSG:${epsgCode}`, | ||
| epsg | ||
| ), | ||
| }) | ||
| featureObject.geometry = transformGeometry( | ||
| featureObject.geometry, | ||
| `EPSG:${epsgCode}`, | ||
| epsg | ||
| ) | ||
| } | ||
| features.push(featureObject) | ||
| }) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import type { Geometry, Point, Polygon } from 'geojson' | ||
|
|
||
| import { transform as transformCoordinates } from 'ol/proj' | ||
|
|
||
| /** | ||
| * Transforms the coordinates of a GeoJSON geometry from one EPSG projection to another. | ||
| * | ||
| * @remarks | ||
| * Currently, supports only Point and Polygon geometries. | ||
| * For unsupported geometry types, an error is thrown. | ||
| * | ||
| * @param geometry - The GeoJSON geometry to transform. | ||
| * @param sourceEpsg - The EPSG code of the source projection. | ||
| * @param targetEpsg - The EPSG code of the target projection. | ||
| * @returns The transformed GeoJSON geometry. | ||
| */ | ||
| export function transformGeometry( | ||
| geometry: Geometry, | ||
| sourceEpsg: string, | ||
| targetEpsg: string | ||
| ): Point | Polygon { | ||
| if (geometry.type === 'Point') { | ||
| return { | ||
| ...geometry, | ||
| coordinates: transformCoordinates( | ||
| geometry.coordinates, | ||
| sourceEpsg, | ||
| targetEpsg | ||
| ), | ||
| } | ||
| } else if (geometry.type === 'Polygon') { | ||
| return { | ||
| ...geometry, | ||
| coordinates: geometry.coordinates.map((ring) => | ||
| ring.map((coord) => transformCoordinates(coord, sourceEpsg, targetEpsg)) | ||
| ), | ||
| } | ||
| } | ||
| throw new Error(`Unsupported geometry type: ${geometry.type}`) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transformCoordinatesincludes the informationSo a call with the same projection does not yield an error, correct?