From 4342b38e9d902492f7cd6fb746fade060c746434 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 29 Mar 2021 02:53:06 +0200 Subject: [PATCH] Formatting and small cleanups --- Customizations/JSON/LayerConfig.ts | 2 +- Customizations/JSON/LayerConfigJson.ts | 60 ++++++++++--------- Folder.DotSettings.user | 2 +- Logic/ExtraFunction.ts | 1 - Logic/FeatureSource/GeoJsonSource.ts | 1 - UI/Popup/TagRenderingQuestion.ts | 3 +- UI/ShowDataLayer.ts | 4 +- .../themes/drinking_water/drinking_water.json | 4 +- 8 files changed, 40 insertions(+), 37 deletions(-) diff --git a/Customizations/JSON/LayerConfig.ts b/Customizations/JSON/LayerConfig.ts index e83a59a..7d85a61 100644 --- a/Customizations/JSON/LayerConfig.ts +++ b/Customizations/JSON/LayerConfig.ts @@ -81,7 +81,7 @@ export default class LayerConfig { this.source = new SourceConfig({ osmTags: osmTags, - geojsonSource: json.source["geoJsonSource"], + geojsonSource: json.source["geoJson"], overpassScript: json.source["overpassScript"], }); } else { diff --git a/Customizations/JSON/LayerConfigJson.ts b/Customizations/JSON/LayerConfigJson.ts index 630699e..b21bb3f 100644 --- a/Customizations/JSON/LayerConfigJson.ts +++ b/Customizations/JSON/LayerConfigJson.ts @@ -10,7 +10,7 @@ export interface LayerConfigJson { * This should be a simple, lowercase, human readable string that is used to identify the layer. */ id: string; - + /** * The name of this layer * Used in the layer control panel and the 'Personal theme' @@ -27,22 +27,24 @@ export interface LayerConfigJson { /** * This determines where the data for the layer is fetched. * There are some options: - * + * * source: {osmTags: "key=value"} will fetch all objects with given tags from OSM. Currently, this will create a query to overpass and fetch the data - in the future this might fetch from the OSM API * source: {geoJsonSource: "https://my.source.net/some-geo-data.geojson"} to fetch a geojson from a third party source - * - * source: {overpassScript: ""} when you want to do special things. _This should be really rare_. + * + * source: {overpassScript: ""} when you want to do special things. _This should be really rare_. * This means that the data will be pulled from overpass with this script, and will ignore the osmTags for the query * However, for the rest of the pipeline, the OsmTags will _still_ be used. This is important to enable layers etc... - * - * + * + * * NOTE: the previous format was 'overpassTags: AndOrTagCOnfigJson | string', which is interpreted as a shorthand for source: {osmTags: "key=value"} * While still supported, this is considered deprecated */ - source: {osmTags: AndOrTagConfigJson | string} | {geoJsonSource: string} | {overpassScript: string} + source: { osmTags: AndOrTagConfigJson | string } | + { osmTags: AndOrTagConfigJson | string, geoJson: string } | + { osmTags: AndOrTagConfigJson | string, overpassScript: string } /** - * + * * A list of extra tags to calculate, specified as "keyToAssignTo=javascript-expression". * There are a few extra functions available. Refer to Docs/CalculatedTags.md for more information * The functions will be run in order, e.g. @@ -50,12 +52,12 @@ export interface LayerConfigJson { * "_max_overlap_m2=Math.max(...feat.overlapsWith("someOtherLayer").map(o => o.overlap)) * "_max_overlap_ratio=Number(feat._max_overlap_m2)/feat.area * ] - * + * */ - calculatedTags? : string[]; + calculatedTags?: string[]; /** - * If set, this layer will not query overpass; but it'll still match the tags above which are by chance returned by other layers. + * If set, this layer will not query overpass; but it'll still match the tags above which are by chance returned by other layers. * Works well together with 'passAllFeatures', to add decoration */ doNotDownload?: boolean; @@ -64,7 +66,7 @@ export interface LayerConfigJson { * This tagrendering should either be 'yes' or 'no'. If 'no' is returned, then the feature will be hidden from view. * This is useful to hide certain features from view. Important: hiding features does not work dynamically, but is only calculated when the data is first renders. * This implies that it is not possible to hide a feature after a tagging change - * + * * The default value is 'yes' */ isShown?: TagRenderingConfigJson; @@ -81,7 +83,7 @@ export interface LayerConfigJson { * Default: 100 (thus: always visible */ maxzoom?: number; - + /** * The title shown in a popup for elements of this layer. */ @@ -97,7 +99,7 @@ export interface LayerConfigJson { /** * The icon for an element. * Note that this also doubles as the icon for this layer (rendered with the overpass-tags) ánd the icon in the presets. - * + * * The result of the icon is rendered as follows: * the resulting string is interpreted as a _list_ of items, seperated by ";". The bottommost layer is the first layer. * As a result, on could use a generic pin, then overlay it with a specific icon. @@ -111,13 +113,13 @@ export interface LayerConfigJson { * The 'badge'-toggle changes their behaviour. * If badge is set, it will be added as a 25% height icon at the bottom right of the icon, with all the badges in a flex layout. * If badges is false, it'll be a simple overlay - * + * * Note: strings are interpreted as icons, so layering and substituting is supported */ - iconOverlays?: {if: string | AndOrTagConfigJson, then: string | TagRenderingConfigJson, badge?: boolean}[] + iconOverlays?: { if: string | AndOrTagConfigJson, then: string | TagRenderingConfigJson, badge?: boolean }[] /** - * A string containing "width,height" or "width,height,anchorpoint" where anchorpoint is any of 'center', 'top', 'bottom', 'left', 'right', 'bottomleft','topright', ... + * A string containing "width,height" or "width,height,anchorpoint" where anchorpoint is any of 'center', 'top', 'bottom', 'left', 'right', 'bottomleft','topright', ... * Default is '40,40,center' */ iconSize?: string | TagRenderingConfigJson; @@ -156,18 +158,18 @@ export interface LayerConfigJson { * If set, this layer will pass all the features it receives onto the next layer. * This is ideal for decoration, e.g. directionss on cameras */ - passAllFeatures?:boolean - + passAllFeatures?: boolean + /** * Presets for this layer. * A preset shows up when clicking the map on a without data (or when right-clicking/long-pressing); * it will prompt the user to add a new point. - * + * * The most important aspect are the tags, which define which tags the new point will have; * The title is shown in the dialog, along with the first sentence of the description. - * + * * Upon confirmation, the full description is shown beneath the buttons - perfect to add pictures and examples. - * + * * Note: the icon of the preset is determined automatically based on the tags and the icon above. Don't worry about that! * NB: if no presets are defined, the popup to add new points doesn't show up at all */ @@ -183,7 +185,7 @@ export interface LayerConfigJson { /** * The _first sentence_ of the description is shown on the button of the `add` menu. * The full description is shown in the confirmation dialog. - * + * * (The first sentence is until the first '.'-character in the description) */ description?: string | any, @@ -192,16 +194,16 @@ export interface LayerConfigJson { /** * All the tag renderings. * A tag rendering is a block that either shows the known value or asks a question. - * + * * Refer to the class `TagRenderingConfigJson` to see the possibilities. - * + * * Note that we can also use a string here - where the string refers to a tagrenering defined in `assets/questions/questions.json`, * where a few very general questions are defined e.g. website, phone number, ... - * + * * A special value is 'questions', which indicates the location of the questions box. If not specified, it'll be appended to the bottom of the featureInfobox. - * + * */ tagRenderings?: (string | TagRenderingConfigJson) [] - - + + } \ No newline at end of file diff --git a/Folder.DotSettings.user b/Folder.DotSettings.user index 1732b9a..e8c3e8e 100644 --- a/Folder.DotSettings.user +++ b/Folder.DotSettings.user @@ -1,5 +1,5 @@  - ShowAndRun + DoNotShowAndRun <SessionState ContinuousTestingMode="0" IsActive="True" Name="Session" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <Nothing /> </SessionState> \ No newline at end of file diff --git a/Logic/ExtraFunction.ts b/Logic/ExtraFunction.ts index e286d1d..1689e67 100644 --- a/Logic/ExtraFunction.ts +++ b/Logic/ExtraFunction.ts @@ -103,7 +103,6 @@ Some advanced functions are available on feat as well: throw "Undefined distance!" } if(closestFeature === undefined || distance < closestDistance){ - console.log("Distance between ", feature.properties.id, "and", otherFeature.properties.id, "is", distance) closestFeature = otherFeature closestDistance = distance; } diff --git a/Logic/FeatureSource/GeoJsonSource.ts b/Logic/FeatureSource/GeoJsonSource.ts index a8d3c79..dea7356 100644 --- a/Logic/FeatureSource/GeoJsonSource.ts +++ b/Logic/FeatureSource/GeoJsonSource.ts @@ -1,7 +1,6 @@ import FeatureSource from "./FeatureSource"; import {UIEventSource} from "../UIEventSource"; import * as $ from "jquery"; -import {Layer} from "leaflet"; /** * Fetches a geojson file somewhere and passes it along diff --git a/UI/Popup/TagRenderingQuestion.ts b/UI/Popup/TagRenderingQuestion.ts index 751e2b7..b8e2c1d 100644 --- a/UI/Popup/TagRenderingQuestion.ts +++ b/UI/Popup/TagRenderingQuestion.ts @@ -57,9 +57,8 @@ export default class TagRenderingQuestion extends UIElement { this._inputElement = this.GenerateInputElement() const self = this; const save = () => { - console.log("Save clicked!") const selection = self._inputElement.GetValue().data; - console.log("Selection is", selection) + console.log("Save button clicked, the tags are is", selection) if (selection) { (State.state?.changes ?? new Changes()) .addTag(tags.data.id, selection, tags); diff --git a/UI/ShowDataLayer.ts b/UI/ShowDataLayer.ts index 9abc487..b077ea3 100644 --- a/UI/ShowDataLayer.ts +++ b/UI/ShowDataLayer.ts @@ -27,7 +27,9 @@ export default class ShowDataLayer { layoutToUse.addCallbackAndRun(layoutToUse => { for (const layer of layoutToUse.layers) { - self._layerDict[layer.id] = layer; + if (self._layerDict[layer.id] === undefined) { + self._layerDict[layer.id] = layer; + } } }); diff --git a/assets/themes/drinking_water/drinking_water.json b/assets/themes/drinking_water/drinking_water.json index 5b5d732..a783e2e 100644 --- a/assets/themes/drinking_water/drinking_water.json +++ b/assets/themes/drinking_water/drinking_water.json @@ -17,6 +17,8 @@ "startLon": 4.3516970, "startZoom": 16, "widenFactor": 0.05, - "layers": ["drinking_water"], + "layers": [ + "drinking_water", + ], "roamingRenderings": [] } \ No newline at end of file