forked from MapComplete/MapComplete
		
	Fix incorrect imports due to refactoring
This commit is contained in:
		
							parent
							
								
									cd1171e678
								
							
						
					
					
						commit
						bec1998a6d
					
				
					 5 changed files with 63 additions and 17 deletions
				
			
		|  | @ -1,12 +1,12 @@ | |||
| import {UIEventSource} from "../UIEventSource"; | ||||
| import Loc from "../../Models/Loc"; | ||||
| import {Or} from "../Or"; | ||||
| import {Or} from "../Tags/Or"; | ||||
| import LayoutConfig from "../../Customizations/JSON/LayoutConfig"; | ||||
| import {Overpass} from "../Osm/Overpass"; | ||||
| import Bounds from "../../Models/Bounds"; | ||||
| import FeatureSource from "../FeatureSource/FeatureSource"; | ||||
| import {Utils} from "../../Utils"; | ||||
| import {TagsFilter} from "../TagsFilter"; | ||||
| import {TagsFilter} from "../Tags/TagsFilter"; | ||||
| 
 | ||||
| 
 | ||||
| export default class UpdateFromOverpass implements FeatureSource { | ||||
|  |  | |||
|  | @ -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", | ||||
|         ["longitude", "latitude"], | ||||
|         (featuresPerLayer, feature) => { | ||||
|             return (lon, lat) => { | ||||
|                 // Feature._lon and ._lat is conveniently place by one of the other metatags
 | ||||
|                 return GeoOperations.distanceBetween([lon, lat], [feature._lon, feature._lat]); | ||||
|             return (arg0, lat) => { | ||||
|                 if(typeof arg0 === "number"){ | ||||
|                     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 _args: string[]; | ||||
|     private readonly _doc: string; | ||||
|  | @ -91,10 +138,10 @@ Some advanced functions are available on <b>feat</b> as well: | |||
|         return new Combine([ | ||||
|             ExtraFunction.intro, | ||||
|             "<ul>", | ||||
|             ...ExtraFunction.allFuncs.map(func =>  | ||||
|             new Combine([ | ||||
|                 "<li>", func._name, "</li>" | ||||
|             ]) | ||||
|             ...ExtraFunction.allFuncs.map(func => | ||||
|                 new Combine([ | ||||
|                     "<li>", func._name, "</li>" | ||||
|                 ]) | ||||
|             ), | ||||
|             "</ul>", | ||||
|             ...ExtraFunction.allFuncs.map(func => | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import {GeoOperations} from "./GeoOperations"; | ||||
| import State from "../State"; | ||||
| import {And} from "./And"; | ||||
| import {Tag} from "./Tag"; | ||||
| import {Or} from "./Or"; | ||||
| import {And} from "./Tags/And"; | ||||
| import {Tag} from "./Tags/Tag"; | ||||
| import {Or} from "./Tags/Or"; | ||||
| import {Utils} from "../Utils"; | ||||
| import opening_hours from "opening_hours"; | ||||
| import {UIElement} from "../UI/UIElement"; | ||||
|  |  | |||
|  | @ -12,8 +12,8 @@ import {FixedUiElement} from "../Base/FixedUiElement"; | |||
| import Translations from "../i18n/Translations"; | ||||
| import Constants from "../../Models/Constants"; | ||||
| import LayerConfig from "../../Customizations/JSON/LayerConfig"; | ||||
| import {Tag} from "../../Logic/Tag"; | ||||
| import {TagUtils} from "../../Logic/TagUtils"; | ||||
| import {Tag} from "../../Logic/Tags/Tag"; | ||||
| import {TagUtils} from "../../Logic/Tags/TagUtils"; | ||||
| 
 | ||||
| export default class SimpleAddUI extends UIElement { | ||||
|     private readonly _loginButton: UIElement; | ||||
|  |  | |||
|  | @ -8,8 +8,7 @@ import TagRenderingAnswer from "./TagRenderingAnswer"; | |||
| import State from "../../State"; | ||||
| import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig"; | ||||
| import ScrollableFullScreen from "../Base/ScrollableFullScreen"; | ||||
| import {Utils} from "../../Utils"; | ||||
| import {Tag} from "../../Logic/Tag"; | ||||
| import {Tag} from "../../Logic/Tags/Tag"; | ||||
| 
 | ||||
| export default class FeatureInfoBox extends ScrollableFullScreen { | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue