forked from MapComplete/MapComplete
Fix bugs with intersectionWith
This commit is contained in:
parent
741564471c
commit
7ca7612960
1 changed files with 15 additions and 10 deletions
|
@ -14,7 +14,7 @@ export interface ExtraFuncParams {
|
|||
*/
|
||||
getFeaturesWithin: (layerId: string, bbox: BBox) => any[][],
|
||||
memberships: RelationsTracker
|
||||
getFeatureById: (id:string) => any
|
||||
getFeatureById: (id: string) => any
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,11 +80,12 @@ class IntersectionFunc implements ExtraFunction {
|
|||
|
||||
_f(params: ExtraFuncParams, feat) {
|
||||
return (...layerIds: string[]) => {
|
||||
const result: { feat: any, intersections: [number,number][] }[] = []
|
||||
const result: { feat: any, intersections: [number, number][] }[] = []
|
||||
|
||||
const bbox = BBox.get(feat)
|
||||
|
||||
for (const layerId of layerIds) {
|
||||
console.log("Calculating the intersection with layer ", layerId)
|
||||
const otherLayers = params.getFeaturesWithin(layerId, bbox)
|
||||
if (otherLayers === undefined) {
|
||||
continue;
|
||||
|
@ -96,7 +97,10 @@ class IntersectionFunc implements ExtraFunction {
|
|||
for (const otherFeature of tile) {
|
||||
|
||||
const intersections = GeoOperations.LineIntersections(feat, otherFeature)
|
||||
result.push({feat, intersections})
|
||||
if(intersections.length === 0){
|
||||
continue
|
||||
}
|
||||
result.push({feat: otherFeature, intersections})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -332,6 +336,7 @@ class GetParsed implements ExtraFunction {
|
|||
_name = "get"
|
||||
_doc = "Gets the property of the feature, parses it (as JSON) and returns it. Might return 'undefined' if not defined, null, ..."
|
||||
_args = ["key"]
|
||||
|
||||
_f(params, feat) {
|
||||
return key => {
|
||||
const value = feat.properties[key]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue