-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from Dataport/feature/add-lasso-logic-to-draw
add lasso logic to draw
- Loading branch information
Showing
20 changed files
with
412 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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,2 +1,7 @@ | ||
export * from './types' | ||
export { getWfsFeatures } from './wfs' | ||
export { parseWfsResponse } from './wfs/parse' | ||
export { | ||
getVectorFeaturesByBboxRequest, | ||
getVectorFeaturesByFeatureRequest, | ||
} from './vector' |
This file contains 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,66 @@ | ||
import { rawLayerList } from '@masterportal/masterportalapi' | ||
import { Feature } from 'ol' | ||
|
||
const supportedFormats = ['OAF', 'WFS'] | ||
|
||
export const getVectorFeaturesByBboxRequest = ({ | ||
bbox, | ||
fetchLayerId, | ||
projectionCode, | ||
}: { | ||
bbox: number[] | ||
fetchLayerId: string | ||
projectionCode: string | ||
}) => { | ||
const serviceDefinition = rawLayerList.getLayerWhere({ id: fetchLayerId }) | ||
if (!supportedFormats.includes(serviceDefinition.typ)) { | ||
throw new Error( | ||
`@polar/lib-get-features#getVectorFeaturesByBboxRequest: Layer with ID "${fetchLayerId}" of type "${serviceDefinition.typ}" was used to retrieve vector data, but is not within the range of supported types [${supportedFormats}].` | ||
) | ||
} | ||
|
||
const [codeName, codeNumber] = projectionCode.split(':') | ||
|
||
const url = | ||
serviceDefinition.typ === 'OAF' | ||
? [ | ||
serviceDefinition.url, | ||
'collections', | ||
serviceDefinition.collection, | ||
`items?f=json&limit=100&bbox=${bbox}&bbox-crs=http://www.opengis.net/def/crs/${codeName}/0/${codeNumber}&crs=http://www.opengis.net/def/crs/${codeName}/0/${codeNumber}`, | ||
].join('/') | ||
: `${serviceDefinition.url}${[ | ||
`?service=${serviceDefinition.typ}`, | ||
`version=${serviceDefinition.version}`, | ||
`request=GetFeature`, | ||
`srsName=${projectionCode}`, | ||
`typeName=${serviceDefinition.featureType}`, | ||
`bbox=${bbox},${projectionCode}`, | ||
].join('&')}` | ||
|
||
return fetch(url) | ||
} | ||
|
||
export const getVectorFeaturesByFeatureRequest = ({ | ||
feature, | ||
fetchLayerId, | ||
projectionCode, | ||
}: { | ||
feature: Feature | ||
fetchLayerId: string | ||
projectionCode: string | ||
}) => { | ||
const bbox = feature.getGeometry()?.getExtent?.() | ||
|
||
if (typeof bbox === 'undefined') { | ||
throw new Error( | ||
'@polar/lib-get-features#getVectorFeaturesByFeatureRequest: Given feature had no extent.' | ||
) | ||
} | ||
|
||
return getVectorFeaturesByBboxRequest({ | ||
bbox, | ||
fetchLayerId, | ||
projectionCode, | ||
}) | ||
} |
This file contains 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 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 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 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 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.