Add better way handling

This commit is contained in:
Pieter Vander Vennet 2020-07-22 00:50:30 +02:00
parent 0bb5abec3c
commit 1373bd106e
10 changed files with 46 additions and 13 deletions

View file

@ -15,7 +15,7 @@ export class LayerDefinition {
/**
* This name is shown in the 'add XXX button'
*/
name: string;
name: string | UIElement;
/**
* These tags are added whenever a new point is added by the user on the map.
* This is the ideal place to add extra info, such as "fixme=added by MapComplete, geometry should be checked"
@ -72,7 +72,15 @@ export class LayerDefinition {
*/
maxAllowedOverlapPercentage: number = undefined;
/**
* If true, then ways (and polygons) will be converted to a 'point' at the center instead before further processing
*/
wayHandling: number = 0;
static WAYHANDLING_DEFAULT = 0;
static WAYHANDLING_CENTER_ONLY = 1;
static WAYHANDLING_CENTER_AND_WAY = 2;
constructor(options: {
name: string,
newElementTags: Tag[],
@ -82,6 +90,7 @@ export class LayerDefinition {
title?: TagRenderingOptions,
elementsToShow?: TagDependantUIElementConstructor[],
maxAllowedOverlapPercentage?: number,
waysToCenterPoints?: boolean,
style?: (tags: any) => {
color: string,
icon: any
@ -99,6 +108,7 @@ export class LayerDefinition {
this.title = options.title;
this.elementsToShow = options.elementsToShow;
this.style = options.style;
this.wayHandling = options.waysToCenterPoints ?? LayerDefinition.WAYHANDLING_DEFAULT;
}
asLayer(basemap: Basemap, allElements: ElementStorage, changes: Changes, userDetails: UIEventSource<UserDetails>, selectedElement: UIEventSource<any>,
@ -109,6 +119,7 @@ export class LayerDefinition {
basemap, allElements, changes,
this.overpassFilter,
this.maxAllowedOverlapPercentage,
this.wayHandling,
this.style,
selectedElement,
showOnPopup);

View file

@ -29,6 +29,7 @@ export default class BikeParkings extends LayerDefinition {
//new ParkingOperator(),
new ParkingType()
];
this.wayHandling = LayerDefinition.WAYHANDLING_CENTER_AND_WAY;
}

View file

@ -27,6 +27,7 @@ export default class BikeShops extends LayerDefinition {
new Tag("shop", "bicycle"),
]
this.maxAllowedOverlapPercentage = 10
this.wayHandling = LayerDefinition.WAYHANDLING_CENTER_AND_WAY
this.minzoom = 13;
this.style = this.generateStyleFunction();

View file

@ -38,6 +38,7 @@ export default class BikeStations extends LayerDefinition {
this.minzoom = 13;
this.style = this.generateStyleFunction();
this.title = new FixedText(Translations.t.cyclofix.station.title)
this.wayHandling = LayerDefinition.WAYHANDLING_CENTER_AND_WAY
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),

View file

@ -24,6 +24,7 @@ export class DrinkingWater extends LayerDefinition {
new Tag("amenity", "drinking_water"),
];
this.maxAllowedOverlapPercentage = 10;
this.wayHandling = LayerDefinition.WAYHANDLING_CENTER_AND_WAY
this.minzoom = 13;
this.style = this.generateStyleFunction();

View file

@ -2,10 +2,8 @@ import {Layout} from "../Layout";
import BikeParkings from "../Layers/BikeParkings";
import BikeServices from "../Layers/BikeStations";
import BikeShops from "../Layers/BikeShops";
import {GhostBike} from "../Layers/GhostBike";
import Translations from "../../UI/i18n/Translations";
import {DrinkingWater} from "../Layers/DrinkingWater";
import {BikeShop} from "../Layers/BikeShop"
import Combine from "../../UI/Base/Combine";