diff --git a/InitUiElements.ts b/InitUiElements.ts index c3e57766a..19f1e3340 100644 --- a/InitUiElements.ts +++ b/InitUiElements.ts @@ -41,6 +41,7 @@ import ShowTileInfo from "./UI/ShowDataLayer/ShowTileInfo"; import {Tiles} from "./Models/TileRange"; import {TileHierarchyAggregator} from "./UI/ShowDataLayer/PerTileCountAggregator"; import {BBox} from "./Logic/GeoOperations"; +import StaticFeatureSource from "./Logic/FeatureSource/Sources/StaticFeatureSource"; export class InitUiElements { static InitAll( @@ -421,9 +422,6 @@ export class InitUiElements { const flayer = { isDisplayed: isDisplayed, layerDef: layer, - isSufficientlyZoomed: state.locationControl.map(l => { - return l.zoom >= (layer.minzoomVisible ?? layer.minzoom) - }), appliedFilters: new UIEventSource(undefined), }; flayers.push(flayer); @@ -491,7 +489,7 @@ export class InitUiElements { return true }, [State.state.locationControl, State.state.currentBounds] ) - + new ShowDataLayer( { features: source, @@ -502,7 +500,6 @@ export class InitUiElements { ); }, state ); - } private static setupAllLayerElements() { diff --git a/Logic/GeoOperations.ts b/Logic/GeoOperations.ts index dd806ded4..cfef09e5d 100644 --- a/Logic/GeoOperations.ts +++ b/Logic/GeoOperations.ts @@ -388,10 +388,10 @@ export class BBox { static global: BBox = new BBox([[-180, -90], [180, 90]]); constructor(coordinates) { - this.maxLat = Number.MIN_VALUE; - this.maxLon = Number.MIN_VALUE; - this.minLat = Number.MAX_VALUE; - this.minLon = Number.MAX_VALUE; + this.maxLat = -90; + this.maxLon = -180; + this.minLat = 90; + this.minLon = 180; for (const coordinate of coordinates) { @@ -491,4 +491,23 @@ export class BBox { toLeaflet() { return [[this.minLat, this.minLon], [this.maxLat, this.maxLon]] } + + asGeoJson(properties: any) : any{ + return { + type:"Feature", + properties: properties, + geometry:{ + type:"Polygon", + coordinates:[[ + + [this.minLon, this.minLat], + [this.maxLon, this.minLat], + [this.maxLon, this.maxLat], + [this.minLon, this.maxLat], + [this.minLon, this.minLat], + + ]] + } + } + } } \ No newline at end of file diff --git a/Logic/SimpleMetaTagger.ts b/Logic/SimpleMetaTagger.ts index b74f0f542..a938e9c72 100644 --- a/Logic/SimpleMetaTagger.ts +++ b/Logic/SimpleMetaTagger.ts @@ -97,6 +97,9 @@ export default class SimpleMetaTagger { continue; } for (const unit of units) { + if(unit === undefined){ + continue + } if (unit.appliesToKeys === undefined) { console.error("The unit ", unit, "has no appliesToKey defined") continue diff --git a/UI/Base/Minimap.ts b/UI/Base/Minimap.ts index 963d39db1..e276c8281 100644 --- a/UI/Base/Minimap.ts +++ b/UI/Base/Minimap.ts @@ -30,6 +30,8 @@ export default class Minimap { /** * Construct a minimap */ - public static createMiniMap: (options: MinimapOptions) => (BaseUIElement & MinimapObj) + public static createMiniMap: (options: MinimapOptions) => (BaseUIElement & MinimapObj) = (_) => { + throw "CreateMinimap hasn't been initialized yet. Please call MinimapImplementation.initialize()" + } } \ No newline at end of file diff --git a/test.ts b/test.ts index 86a1c8f6e..c70e45da5 100644 --- a/test.ts +++ b/test.ts @@ -5,46 +5,29 @@ import MinimapImplementation from "./UI/Base/MinimapImplementation"; import {UIEventSource} from "./Logic/UIEventSource"; import FilteredLayer from "./Models/FilteredLayer"; import {And} from "./Logic/Tags/And"; +import ShowDataLayer from "./UI/ShowDataLayer/ShowDataLayer"; +import ShowTileInfo from "./UI/ShowDataLayer/ShowTileInfo"; +import StaticFeatureSource from "./Logic/FeatureSource/Sources/StaticFeatureSource"; +import {BBox} from "./Logic/GeoOperations"; +import Minimap from "./UI/Base/Minimap"; -const layout = AllKnownLayouts.allKnownLayouts.get("cyclestreets") -State.state = new State(layout) +State.state = new State(undefined) + +const leafletMap = new UIEventSource(undefined) MinimapImplementation.initialize() -const feature = { - "type": "Feature", - "properties": { - id: "way/1234", - "highway":"residential", - "cyclestreet":"yes" - }, - "geometry": { - "type": "LineString", - "coordinates": [ - [ - 3.2207107543945312, - 51.21978729870313 - ], - [ - 3.2198524475097656, - 51.21899435057332 - ], - [ - 3.2155394554138184, - 51.21617188199714 - ] - ] - } -} +Minimap.createMiniMap({ + leafletMap: leafletMap, +}).SetStyle("height: 600px; width: 600px") + .AttachTo("maindiv") -State.state.allElements.addOrGetElement(feature) -State.state.filteredLayers = new UIEventSource( - layout.layers.map( l => ({ - layerDef :l, - appliedFilters: new UIEventSource(undefined), - isDisplayed: new UIEventSource(undefined) - })) -) +const bbox = BBox.fromTile(16,32754,21785).asGeoJson({ + count: 42, + tileId: 42 +}) -const splitroad = new SplitRoadWizard("way/1234") - splitroad.AttachTo("maindiv") - -splitroad.dialogIsOpened.setData(true) +console.log(bbox) +new ShowDataLayer({ + layerToShow: ShowTileInfo.styling, + leafletMap: leafletMap, + features: new StaticFeatureSource([ bbox], false) +}) \ No newline at end of file diff --git a/test/GeoOperations.spec.ts b/test/GeoOperations.spec.ts index 7a556b20d..49447afd5 100644 --- a/test/GeoOperations.spec.ts +++ b/test/GeoOperations.spec.ts @@ -1,7 +1,8 @@ import {Utils} from "../Utils"; import * as Assert from "assert"; import T from "./TestHelper"; -import {GeoOperations} from "../Logic/GeoOperations"; +import {BBox, GeoOperations} from "../Logic/GeoOperations"; +import {equal} from "assert"; Utils.runningFromConsole = true; @@ -176,7 +177,16 @@ export default class GeoOperationsSpec extends T { const overlap = GeoOperations.calculateOverlap(point, [GeoOperationsSpec.polygon]); Assert.equal(1, overlap.length) - }] + }], + ["bbox bounds test", + () => { + const bbox = BBox.fromTile(16, 32754, 21785) + equal(-0.0714111328125, bbox.minLon) + equal(-0.076904296875, bbox.maxLon) + equal(51.53266860674158, bbox.minLat) + equal(51.5292513551899, bbox.maxLat) + } + ] ] )