forked from MapComplete/MapComplete
Add multi-apply box/feature, use it in etymology-theme to apply tags onto all segments of the same street
This commit is contained in:
parent
d0dfe9f607
commit
d3550fefbe
22 changed files with 355 additions and 78 deletions
|
@ -119,7 +119,7 @@ export class ExtraFunction {
|
|||
{
|
||||
name: "closest",
|
||||
doc: "Given either a list of geojson features or a single layer name, gives the single object which is nearest to the feature. In the case of ways/polygons, only the centerpoint is considered. Returns a single geojson feature or undefined if nothing is found (or not yet laoded)",
|
||||
args: ["list of features"]
|
||||
args: ["list of features or a layer name or '*' to get all features"]
|
||||
},
|
||||
(params, feature) => {
|
||||
return (features) => ExtraFunction.GetClosestNFeatures(params, feature, features)?.[0]?.feat
|
||||
|
@ -132,7 +132,7 @@ export class ExtraFunction {
|
|||
doc: "Given either a list of geojson features or a single layer name, gives the n closest objects which are nearest to the feature (excluding the feature itself). In the case of ways/polygons, only the centerpoint is considered. " +
|
||||
"Returns a list of `{feat: geojson, distance:number}` the empty list if nothing is found (or not yet loaded)\n\n" +
|
||||
"If a 'unique tag key' is given, the tag with this key will only appear once (e.g. if 'name' is given, all features will have a different name)",
|
||||
args: ["list of features or layer name", "amount of features", "unique tag key (optional)", "maxDistanceInMeters (optional)"]
|
||||
args: ["list of features or layer name or '*' to get all features", "amount of features", "unique tag key (optional)", "maxDistanceInMeters (optional)"]
|
||||
},
|
||||
(params, feature) => {
|
||||
|
||||
|
|
|
@ -402,6 +402,9 @@ export default class FeaturePipeline {
|
|||
}
|
||||
|
||||
public GetFeaturesWithin(layerId: string, bbox: BBox): any[][] {
|
||||
if(layerId === "*"){
|
||||
return this.GetAllFeaturesWithin(bbox)
|
||||
}
|
||||
const requestedHierarchy = this.perLayerHierarchy.get(layerId)
|
||||
if (requestedHierarchy === undefined) {
|
||||
console.warn("Layer ", layerId, "is not defined. Try one of ", Array.from(this.perLayerHierarchy.keys()))
|
||||
|
|
|
@ -55,7 +55,6 @@ export default abstract class ImageProvider {
|
|||
}
|
||||
seenValues.add(value)
|
||||
this.ExtractUrls(key, value).then(promises => {
|
||||
console.log("Got ", promises.length, "promises for", value,"by",self.constructor.name)
|
||||
for (const promise of promises ?? []) {
|
||||
if (promise === undefined) {
|
||||
continue
|
||||
|
|
|
@ -27,7 +27,6 @@ export class WikidataImageProvider extends ImageProvider {
|
|||
if(entity === undefined){
|
||||
return []
|
||||
}
|
||||
console.log("Entity:", entity)
|
||||
|
||||
const allImages : Promise<ProvidedImage>[] = []
|
||||
// P18 is the claim 'depicted in this image'
|
||||
|
|
|
@ -64,12 +64,12 @@ export default class MetaTagging {
|
|||
if(metatag.isLazy){
|
||||
somethingChanged = true;
|
||||
|
||||
metatag.applyMetaTagsOnFeature(feature, freshness)
|
||||
metatag.applyMetaTagsOnFeature(feature, freshness, layer)
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
const newValueAdded = metatag.applyMetaTagsOnFeature(feature, freshness)
|
||||
const newValueAdded = metatag.applyMetaTagsOnFeature(feature, freshness, layer)
|
||||
/* Note that the expression:
|
||||
* `somethingChanged = newValueAdded || metatag.applyMetaTagsOnFeature(feature, freshness)`
|
||||
* Is WRONG
|
||||
|
|
|
@ -6,6 +6,7 @@ import Combine from "../UI/Base/Combine";
|
|||
import BaseUIElement from "../UI/BaseUIElement";
|
||||
import Title from "../UI/Base/Title";
|
||||
import {FixedUiElement} from "../UI/Base/FixedUiElement";
|
||||
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
|
||||
|
||||
|
||||
const cardinalDirections = {
|
||||
|
@ -62,6 +63,20 @@ export default class SimpleMetaTagger {
|
|||
return true;
|
||||
})
|
||||
);
|
||||
private static layerInfo = new SimpleMetaTagger(
|
||||
{
|
||||
doc: "The layer-id to which this feature belongs. Note that this might be return any applicable if `passAllFeatures` is defined.",
|
||||
keys:["_layer"],
|
||||
includesDates: false,
|
||||
},
|
||||
(feature, freshness, layer) => {
|
||||
if(feature.properties._layer === layer.id){
|
||||
return false;
|
||||
}
|
||||
feature.properties._layer = layer.id
|
||||
return true;
|
||||
}
|
||||
)
|
||||
private static surfaceArea = new SimpleMetaTagger(
|
||||
{
|
||||
keys: ["_surface", "_surface:ha"],
|
||||
|
@ -329,6 +344,7 @@ export default class SimpleMetaTagger {
|
|||
)
|
||||
public static metatags = [
|
||||
SimpleMetaTagger.latlon,
|
||||
SimpleMetaTagger.layerInfo,
|
||||
SimpleMetaTagger.surfaceArea,
|
||||
SimpleMetaTagger.lngth,
|
||||
SimpleMetaTagger.canonicalize,
|
||||
|
@ -346,7 +362,7 @@ export default class SimpleMetaTagger {
|
|||
public readonly doc: string;
|
||||
public readonly isLazy: boolean;
|
||||
public readonly includesDates: boolean
|
||||
public readonly applyMetaTagsOnFeature: (feature: any, freshness: Date) => boolean;
|
||||
public readonly applyMetaTagsOnFeature: (feature: any, freshness: Date, layer: LayerConfig) => boolean;
|
||||
|
||||
/***
|
||||
* A function that adds some extra data to a feature
|
||||
|
@ -354,7 +370,7 @@ export default class SimpleMetaTagger {
|
|||
* @param f: apply the changes. Returns true if something changed
|
||||
*/
|
||||
constructor(docs: { keys: string[], doc: string, includesDates?: boolean, isLazy?: boolean },
|
||||
f: ((feature: any, freshness: Date) => boolean)) {
|
||||
f: ((feature: any, freshness: Date, layer: LayerConfig) => boolean)) {
|
||||
this.keys = docs.keys;
|
||||
this.doc = docs.doc;
|
||||
this.isLazy = docs.isLazy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue