diff --git a/Logic/ExtraFunction.ts b/Logic/ExtraFunction.ts index df7e3a585..a3e12567f 100644 --- a/Logic/ExtraFunction.ts +++ b/Logic/ExtraFunction.ts @@ -54,10 +54,10 @@ export class ExtraFunction { private static readonly OverlapFunc = new ExtraFunction( { name: "overlapWith", - doc: "Gives a list of features from the specified layer which this feature (partly) overlaps with. " + - "If the current feature is a point, all features that embed the point are given. " + + doc: "Gives a list of features from the specified layer which this feature (partly) overlaps with. A point which is embedded in the feature is detected as well." + + "If the current feature is a point, all features that this point is embeded in are given.\n\n" + "The returned value is `{ feat: GeoJSONFeature, overlap: number}[]` where `overlap` is the overlapping surface are (in m²) for areas, the overlapping length (in meter) if the current feature is a line or `undefined` if the current feature is a point.\n" + - "The resulting list is sorted in descending order by overlap. The feature with the most overlap will thus be the first in the list" + + "The resulting list is sorted in descending order by overlap. The feature with the most overlap will thus be the first in the list\n" + "\n" + "For example to get all objects which overlap or embed from a layer, use `_contained_climbing_routes_properties=feat.overlapWith('climbing_route')`", args: ["...layerIds - one or more layer ids of the layer from which every feature is checked for overlap)"] @@ -233,7 +233,7 @@ export class ExtraFunction { return new Combine([ ExtraFunction.intro, - new List(ExtraFunction.allFuncs.map(func => func._name)), + new List(ExtraFunction.allFuncs.map(func => `[${func._name}](#${func._name})`)), ...elems ]); } diff --git a/Logic/GeoOperations.ts b/Logic/GeoOperations.ts index b5c9e4c45..a4fd2ea35 100644 --- a/Logic/GeoOperations.ts +++ b/Logic/GeoOperations.ts @@ -37,8 +37,10 @@ export class GeoOperations { * The features with which 'feature' overlaps, are returned together with their overlap area in m² * * If 'feature' is a LineString, the features in which this feature is (partly) embedded is returned, the overlap length in meter is given + * If 'feature' is a Polygon, overlapping points and points within the polygon will be returned * * If 'feature' is a point, it will return every feature the point is embedded in. Overlap will be undefined + * */ static calculateOverlap(feature: any, otherFeatures: any[]): { feat: any, overlap: number }[] { diff --git a/Models/ThemeConfig/LayerConfig.ts b/Models/ThemeConfig/LayerConfig.ts index 3ef796cd7..5c8090d61 100644 --- a/Models/ThemeConfig/LayerConfig.ts +++ b/Models/ThemeConfig/LayerConfig.ts @@ -192,11 +192,11 @@ export default class LayerConfig extends WithContextLoader { } this.mapRendering = json.mapRendering - .filter(r => r["icon"] !== undefined || r["label"] !== undefined) + .filter(r => r["location"] !== undefined) .map((r, i) => new PointRenderingConfig(r, context + ".mapRendering[" + i + "]")) this.lineRendering = json.mapRendering - .filter(r => r["icon"] === undefined && r["label"] === undefined) + .filter(r => r["location"] === undefined) .map((r, i) => new LineRenderingConfig(r, context + ".mapRendering[" + i + "]")) diff --git a/Models/ThemeConfig/PointRenderingConfig.ts b/Models/ThemeConfig/PointRenderingConfig.ts index 90fde701d..911a2ed54 100644 --- a/Models/ThemeConfig/PointRenderingConfig.ts +++ b/Models/ThemeConfig/PointRenderingConfig.ts @@ -39,6 +39,10 @@ export default class PointRenderingConfig extends WithContextLoader { throw `A point rendering has an invalid location: '${l}' is not one of ${Array.from(allowed).join(", ")} (at ${context}.location)` } }) + + if(json.icon === undefined && json.label === undefined){ + throw `A point rendering should define at least an icon or a label` + } if(this.location.size == 0){ throw "A pointRendering should have at least one 'location' to defined where it should be rendered. (At "+context+".location)" diff --git a/UI/AllThemesGui.ts b/UI/AllThemesGui.ts index be4e0d6e4..ec5e2481d 100644 --- a/UI/AllThemesGui.ts +++ b/UI/AllThemesGui.ts @@ -7,11 +7,14 @@ import UserRelatedState from "../Logic/State/UserRelatedState"; import {Utils} from "../Utils"; import LanguagePicker from "./LanguagePicker"; import IndexText from "./BigComponents/IndexText"; -import {feature} from "@turf/turf"; import FeaturedMessage from "./BigComponents/FeaturedMessage"; +import {AllKnownLayouts} from "../Customizations/AllKnownLayouts"; export default class AllThemesGui { constructor() { + + try{ + new FixedUiElement("").AttachTo("centermessage") const state = new UserRelatedState(undefined); const intro = new Combine([ @@ -30,5 +33,9 @@ export default class AllThemesGui { ]).SetClass("block m-5 lg:w-3/4 lg:ml-40") .SetStyle("pointer-events: all;") .AttachTo("topleft-tools"); + }catch (e) { + new FixedUiElement("Seems like no layers are compiled - check the output of `npm run generate:layeroverview`. Is this visible online? Contact pietervdvn immediately!").SetClass("alert") + .AttachTo("centermessage") + } } -} \ No newline at end of file +} diff --git a/assets/themes/speelplekken/speelplekken.json b/assets/themes/speelplekken/speelplekken.json index 175f7685b..ad8255ed4 100644 --- a/assets/themes/speelplekken/speelplekken.json +++ b/assets/themes/speelplekken/speelplekken.json @@ -38,11 +38,6 @@ "render": "1" }, "mapRendering": [ - { - "location": [ - "point" - ] - }, { "color": "#444444", "width": { diff --git a/assets/themes/uk_addresses/uk_addresses.json b/assets/themes/uk_addresses/uk_addresses.json index fc980965a..e289c2981 100644 --- a/assets/themes/uk_addresses/uk_addresses.json +++ b/assets/themes/uk_addresses/uk_addresses.json @@ -51,10 +51,37 @@ } ], "layers": [ + { + "id": "raw_inspire_polygons", + "source": { + "geoJson": "https://osm-uk-addresses.russss.dev/inspire/{z}/{x}/{y}.json", + "osmTags": "inspireid~*", + "geoJsonZoomLevel": 18, + "isOsmCache": false + }, + "minzoom": 18, + "calculatedTags": [ + "_has_address=feat.overlapWith('addresses').length > 0" + ], + "#mapRendering": [ + { + "width": 2, + "color": { + "render": "#00f", + "mappings": [ + { + "if": "_has_address=true", + "then": "#0f0" + } + ] + } + } + ], + "mapRendering": [] + }, { "id": "to_import", "source": { - "#geoJson": "https://raw.githubusercontent.com/pietervdvn/MapComplete/develop/assets/themes/uk_addresses/islington_small_piece.geojson", "geoJson": "https://osm-uk-addresses.russss.dev/addresses/{z}/{x}/{y}.json", "osmTags": "inspireid~*", "geoJsonZoomLevel": 16, @@ -73,18 +100,26 @@ { "id": "uk_addresses_embedding_outline", "render": "An outline embedding this point with an address already exists in OpenStreetMap.
This object has address {_embedding_object:addr:street} {_embedding_object:addr:housenumber}", + "mappings": [{ + "if": "_embedding_object:id=true", + "then": "The INSPIRE-polygon containing this point has at least one address contained" + },{ + "if": "_embedding_object:id=false", + "then": "The INSPIRE-polygon containing this point has no addresses contained" + }], "condition": "_embedding_object:id~*" }, { "id": "uk_addresses_import_button", - "render": "{import_button(ref:inspireid=$inspireid, Add this address, ./assets/themes/uk_addresses/housenumber_add.svg)}" + "render": "{import_button(addresses,ref:inspireid=$inspireid, Add this address, ./assets/themes/uk_addresses/housenumber_add.svg)}" } ], "calculatedTags": [ "_embedding_object=feat.overlapWith('addresses')[0]?.feat?.properties ?? null", "_embedding_object:addr:housenumber=JSON.parse(feat.properties._embedding_object)?.['addr:housenumber']", "_embedding_object:addr:street=JSON.parse(feat.properties._embedding_object)?.['addr:street']", - "_embedding_object:id=JSON.parse(feat.properties._embedding_object)?.id" + "_embedding_inspire_polygon_has_address=feat.overlapWith('raw_inspire_polygons')[0]?.feat?.properties?._has_address", + "_embedding_object:id=feat.get('_embedding_object')?.id ?? feat.properties._embedding_inspire_polygon_has_address" ], "filter": [ { @@ -95,7 +130,12 @@ "osmTags": { "and": [ "_imported=", - "_embedding_object:id=" + { + "or": [ + "_embedding_object:id=", + "_embedding_object:id=false" + ] + } ] } } @@ -108,7 +148,12 @@ "render": "./assets/themes/uk_addresses/housenumber_unknown.svg", "mappings": [ { - "if": "_embedding_object:id~*", + "if": { + "and": [ + "_embedding_object:id~*", + "_embedding_object:id!=false" + ] + }, "then": "./assets/themes/uk_addresses/housenumber_unknown_small.svg" }, { @@ -302,11 +347,6 @@ } }, "mapRendering": [ - { - "location": [ - "point" - ] - }, { "color": { "render": "#ccc"