Fix incorrect imports due to refactoring

This commit is contained in:
pietervdvn 2021-03-29 02:04:42 +02:00
parent cd1171e678
commit bec1998a6d
5 changed files with 63 additions and 17 deletions

View file

@ -1,12 +1,12 @@
import {UIEventSource} from "../UIEventSource"; import {UIEventSource} from "../UIEventSource";
import Loc from "../../Models/Loc"; import Loc from "../../Models/Loc";
import {Or} from "../Or"; import {Or} from "../Tags/Or";
import LayoutConfig from "../../Customizations/JSON/LayoutConfig"; import LayoutConfig from "../../Customizations/JSON/LayoutConfig";
import {Overpass} from "../Osm/Overpass"; import {Overpass} from "../Osm/Overpass";
import Bounds from "../../Models/Bounds"; import Bounds from "../../Models/Bounds";
import FeatureSource from "../FeatureSource/FeatureSource"; import FeatureSource from "../FeatureSource/FeatureSource";
import {Utils} from "../../Utils"; import {Utils} from "../../Utils";
import {TagsFilter} from "../TagsFilter"; import {TagsFilter} from "../Tags/TagsFilter";
export default class UpdateFromOverpass implements FeatureSource { export default class UpdateFromOverpass implements FeatureSource {

View file

@ -61,13 +61,60 @@ Some advanced functions are available on <b>feat</b> as well:
"Calculates the distance between the feature and a specified point", "Calculates the distance between the feature and a specified point",
["longitude", "latitude"], ["longitude", "latitude"],
(featuresPerLayer, feature) => { (featuresPerLayer, feature) => {
return (lon, lat) => { return (arg0, lat) => {
// Feature._lon and ._lat is conveniently place by one of the other metatags if(typeof arg0 === "number"){
return GeoOperations.distanceBetween([lon, lat], [feature._lon, feature._lat]); const lon = arg0
// Feature._lon and ._lat is conveniently place by one of the other metatags
return GeoOperations.distanceBetween([lon, lat], [feature._lon, feature._lat]);
}else{
// arg0 is probably a feature
return GeoOperations.distanceBetween(GeoOperations.centerpointCoordinates(arg0),[feature._lon, feature._lat])
}
} }
} }
) )
private static readonly allFuncs: ExtraFunction[] = [ExtraFunction.DistanceToFunc, ExtraFunction.OverlapFunc];
private static ClosestObjectFunc = new ExtraFunction(
"closest",
"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.",
["list of features"],
(featuresPerLayer, feature) => {
return (features) => {
if (typeof features === "string") {
features = featuresPerLayer.get(features)
}
let closestFeature = undefined;
let closestDistance = undefined;
for (const otherFeature of features) {
if(otherFeature == feature){
continue; // We ignore self
}
let distance = undefined;
if (otherFeature._lon !== undefined && otherFeature._lat !== undefined) {
distance = GeoOperations.distanceBetween([otherFeature._lon, otherFeature._lat], [feature._lon, feature._lat]);
} else {
distance = GeoOperations.distanceBetween(
GeoOperations.centerpointCoordinates(otherFeature),
[feature._lon, feature._lat]
)
}
if(distance === undefined){
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;
}
}
return closestFeature;
}
}
)
private static readonly allFuncs: ExtraFunction[] = [ExtraFunction.DistanceToFunc, ExtraFunction.OverlapFunc, ExtraFunction.ClosestObjectFunc];
private readonly _name: string; private readonly _name: string;
private readonly _args: string[]; private readonly _args: string[];
private readonly _doc: string; private readonly _doc: string;
@ -91,10 +138,10 @@ Some advanced functions are available on <b>feat</b> as well:
return new Combine([ return new Combine([
ExtraFunction.intro, ExtraFunction.intro,
"<ul>", "<ul>",
...ExtraFunction.allFuncs.map(func => ...ExtraFunction.allFuncs.map(func =>
new Combine([ new Combine([
"<li>", func._name, "</li>" "<li>", func._name, "</li>"
]) ])
), ),
"</ul>", "</ul>",
...ExtraFunction.allFuncs.map(func => ...ExtraFunction.allFuncs.map(func =>

View file

@ -1,8 +1,8 @@
import {GeoOperations} from "./GeoOperations"; import {GeoOperations} from "./GeoOperations";
import State from "../State"; import State from "../State";
import {And} from "./And"; import {And} from "./Tags/And";
import {Tag} from "./Tag"; import {Tag} from "./Tags/Tag";
import {Or} from "./Or"; import {Or} from "./Tags/Or";
import {Utils} from "../Utils"; import {Utils} from "../Utils";
import opening_hours from "opening_hours"; import opening_hours from "opening_hours";
import {UIElement} from "../UI/UIElement"; import {UIElement} from "../UI/UIElement";

View file

@ -12,8 +12,8 @@ import {FixedUiElement} from "../Base/FixedUiElement";
import Translations from "../i18n/Translations"; import Translations from "../i18n/Translations";
import Constants from "../../Models/Constants"; import Constants from "../../Models/Constants";
import LayerConfig from "../../Customizations/JSON/LayerConfig"; import LayerConfig from "../../Customizations/JSON/LayerConfig";
import {Tag} from "../../Logic/Tag"; import {Tag} from "../../Logic/Tags/Tag";
import {TagUtils} from "../../Logic/TagUtils"; import {TagUtils} from "../../Logic/Tags/TagUtils";
export default class SimpleAddUI extends UIElement { export default class SimpleAddUI extends UIElement {
private readonly _loginButton: UIElement; private readonly _loginButton: UIElement;

View file

@ -8,8 +8,7 @@ import TagRenderingAnswer from "./TagRenderingAnswer";
import State from "../../State"; import State from "../../State";
import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig"; import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig";
import ScrollableFullScreen from "../Base/ScrollableFullScreen"; import ScrollableFullScreen from "../Base/ScrollableFullScreen";
import {Utils} from "../../Utils"; import {Tag} from "../../Logic/Tags/Tag";
import {Tag} from "../../Logic/Tag";
export default class FeatureInfoBox extends ScrollableFullScreen { export default class FeatureInfoBox extends ScrollableFullScreen {