forked from MapComplete/MapComplete
Housekeeping...
This commit is contained in:
parent
707b25529b
commit
6d822b42ca
158 changed files with 7939 additions and 11272 deletions
|
@ -1,24 +1,28 @@
|
|||
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig"
|
||||
import {QueryParameters} from "./Web/QueryParameters"
|
||||
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts"
|
||||
import {FixedUiElement} from "../UI/Base/FixedUiElement"
|
||||
import {Utils} from "../Utils"
|
||||
import { QueryParameters } from "./Web/QueryParameters"
|
||||
import { AllKnownLayouts } from "../Customizations/AllKnownLayouts"
|
||||
import { FixedUiElement } from "../UI/Base/FixedUiElement"
|
||||
import { Utils } from "../Utils"
|
||||
import Combine from "../UI/Base/Combine"
|
||||
import {SubtleButton} from "../UI/Base/SubtleButton"
|
||||
import { SubtleButton } from "../UI/Base/SubtleButton"
|
||||
import BaseUIElement from "../UI/BaseUIElement"
|
||||
import {UIEventSource} from "./UIEventSource"
|
||||
import {LocalStorageSource} from "./Web/LocalStorageSource"
|
||||
import { UIEventSource } from "./UIEventSource"
|
||||
import { LocalStorageSource } from "./Web/LocalStorageSource"
|
||||
import LZString from "lz-string"
|
||||
import {FixLegacyTheme} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert"
|
||||
import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson"
|
||||
import { FixLegacyTheme } from "../Models/ThemeConfig/Conversion/LegacyJsonConvert"
|
||||
import { LayerConfigJson } from "../Models/ThemeConfig/Json/LayerConfigJson"
|
||||
import SharedTagRenderings from "../Customizations/SharedTagRenderings"
|
||||
import * as known_layers from "../assets/generated/known_layers.json"
|
||||
import {PrepareTheme} from "../Models/ThemeConfig/Conversion/PrepareTheme"
|
||||
import { PrepareTheme } from "../Models/ThemeConfig/Conversion/PrepareTheme"
|
||||
import * as licenses from "../assets/generated/license_info.json"
|
||||
import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig"
|
||||
import {FixImages} from "../Models/ThemeConfig/Conversion/FixImages"
|
||||
import { FixImages } from "../Models/ThemeConfig/Conversion/FixImages"
|
||||
import Svg from "../Svg"
|
||||
import {DoesImageExist, PrevalidateTheme, ValidateThemeAndLayers} from "../Models/ThemeConfig/Conversion/Validation";
|
||||
import {
|
||||
DoesImageExist,
|
||||
PrevalidateTheme,
|
||||
ValidateThemeAndLayers,
|
||||
} from "../Models/ThemeConfig/Conversion/Validation"
|
||||
|
||||
export default class DetermineLayout {
|
||||
private static readonly _knownImages = new Set(Array.from(licenses).map((l) => l.path))
|
||||
|
@ -130,11 +134,11 @@ export default class DetermineLayout {
|
|||
}),
|
||||
json !== undefined
|
||||
? new SubtleButton(Svg.download_svg(), "Download the JSON file").onClick(() => {
|
||||
Utils.offerContentsAsDownloadableFile(
|
||||
JSON.stringify(json, null, " "),
|
||||
"theme_definition.json"
|
||||
)
|
||||
})
|
||||
Utils.offerContentsAsDownloadableFile(
|
||||
JSON.stringify(json, null, " "),
|
||||
"theme_definition.json"
|
||||
)
|
||||
})
|
||||
: undefined,
|
||||
])
|
||||
.SetClass("flex flex-col clickable")
|
||||
|
@ -181,14 +185,14 @@ export default class DetermineLayout {
|
|||
json.id = forceId ?? json.id
|
||||
|
||||
{
|
||||
let {errors} = new PrevalidateTheme().convert(json, "validation")
|
||||
let { errors } = new PrevalidateTheme().convert(json, "validation")
|
||||
if (errors.length > 0) {
|
||||
throw "Detected errors: " + errors.join("\n")
|
||||
}
|
||||
}
|
||||
{
|
||||
let {errors} = new ValidateThemeAndLayers(
|
||||
new DoesImageExist(new Set<string>(), _ => true),
|
||||
let { errors } = new ValidateThemeAndLayers(
|
||||
new DoesImageExist(new Set<string>(), (_) => true),
|
||||
"",
|
||||
false,
|
||||
SharedTagRenderings.SharedTagRendering
|
||||
|
|
|
@ -8,12 +8,13 @@ import {
|
|||
booleanWithin,
|
||||
Coord,
|
||||
Feature,
|
||||
Geometry, Lines,
|
||||
Geometry,
|
||||
Lines,
|
||||
MultiPolygon,
|
||||
Polygon,
|
||||
Properties,
|
||||
} from "@turf/turf"
|
||||
import {GeoJSON, LineString, Point} from "geojson";
|
||||
import { GeoJSON, LineString, Point } from "geojson"
|
||||
|
||||
export class GeoOperations {
|
||||
private static readonly _earthRadius = 6378137
|
||||
|
@ -28,7 +29,7 @@ export class GeoOperations {
|
|||
* @param feature
|
||||
*/
|
||||
static centerpoint(feature: any): Feature<Point> {
|
||||
const newFeature : Feature<Point> = turf.center(feature)
|
||||
const newFeature: Feature<Point> = turf.center(feature)
|
||||
newFeature.properties = feature.properties
|
||||
newFeature.id = feature.id
|
||||
return newFeature
|
||||
|
@ -286,10 +287,10 @@ export class GeoOperations {
|
|||
way = { ...way }
|
||||
way.geometry = { ...way.geometry }
|
||||
way.geometry.type = "LineString"
|
||||
way.geometry.coordinates = (<Polygon> way.geometry).coordinates[0]
|
||||
way.geometry.coordinates = (<Polygon>way.geometry).coordinates[0]
|
||||
}
|
||||
|
||||
return turf.nearestPointOnLine(<Feature<LineString>> way, point, { units: "kilometers" })
|
||||
return turf.nearestPointOnLine(<Feature<LineString>>way, point, { units: "kilometers" })
|
||||
}
|
||||
|
||||
public static toCSV(features: any[]): string {
|
||||
|
|
|
@ -9,7 +9,7 @@ import LayerConfig from "../Models/ThemeConfig/LayerConfig"
|
|||
import { CountryCoder } from "latlon2country"
|
||||
import Constants from "../Models/Constants"
|
||||
import { TagUtils } from "./Tags/TagUtils"
|
||||
import {Feature, LineString} from "geojson";
|
||||
import { Feature, LineString } from "geojson"
|
||||
|
||||
export class SimpleMetaTagger {
|
||||
public readonly keys: string[]
|
||||
|
@ -424,23 +424,26 @@ export default class SimpleMetaTaggers {
|
|||
|
||||
private static directionCenterpoint = new SimpleMetaTagger(
|
||||
{
|
||||
keys:["_direction:centerpoint"],
|
||||
keys: ["_direction:centerpoint"],
|
||||
isLazy: true,
|
||||
doc: "_direction:centerpoint is the direction of the linestring (in degrees) if one were standing at the projected centerpoint."
|
||||
doc: "_direction:centerpoint is the direction of the linestring (in degrees) if one were standing at the projected centerpoint.",
|
||||
},
|
||||
(feature: Feature) => {
|
||||
if(feature.geometry.type !== "LineString"){
|
||||
if (feature.geometry.type !== "LineString") {
|
||||
return false
|
||||
}
|
||||
|
||||
const ls = <Feature<LineString>> feature;
|
||||
const ls = <Feature<LineString>>feature
|
||||
|
||||
Object.defineProperty(feature.properties, "_direction:centerpoint", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
get: () => {
|
||||
const centroid = GeoOperations.centerpoint(feature)
|
||||
const projected = GeoOperations.nearestPoint(ls, <[number,number]> centroid.geometry.coordinates)
|
||||
const projected = GeoOperations.nearestPoint(
|
||||
ls,
|
||||
<[number, number]>centroid.geometry.coordinates
|
||||
)
|
||||
const nextPoint = ls.geometry.coordinates[projected.properties.index + 1]
|
||||
const bearing = GeoOperations.bearing(projected.geometry.coordinates, nextPoint)
|
||||
delete feature.properties["_direction:centerpoint"]
|
||||
|
|
|
@ -681,14 +681,20 @@ export class UIEventSource<T> extends Store<T> {
|
|||
/**
|
||||
* Monoidal map which results in a read-only store. 'undefined' is passed 'as is'
|
||||
* Given a function 'f', will construct a new UIEventSource where the contents will always be "f(this.data)'
|
||||
*/
|
||||
*/
|
||||
public mapD<J>(f: (t: T) => J, extraSources: Store<any>[] = []): Store<J | undefined> {
|
||||
return new MappedStore(this, t => {
|
||||
if(t === undefined){
|
||||
return undefined
|
||||
}
|
||||
return f(t)
|
||||
}, extraSources, this._callbacks, this.data === undefined ? undefined : f(this.data))
|
||||
return new MappedStore(
|
||||
this,
|
||||
(t) => {
|
||||
if (t === undefined) {
|
||||
return undefined
|
||||
}
|
||||
return f(t)
|
||||
},
|
||||
extraSources,
|
||||
this._callbacks,
|
||||
this.data === undefined ? undefined : f(this.data)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue