forked from MapComplete/MapComplete
Merge develop
This commit is contained in:
commit
bef05481bd
239 changed files with 11612 additions and 1347 deletions
|
@ -139,10 +139,14 @@ export default class GeoLocationHandler {
|
|||
private CopyGeolocationIntoMapstate() {
|
||||
const features: UIEventSource<Feature[]> = new UIEventSource<Feature[]>([])
|
||||
this.currentUserLocation = new StaticFeatureSource(features)
|
||||
// For some weird reason, the 'Object.keys' method doesn't work for the 'location: GeolocationCoordinates'-object and will thus not copy all the properties when using {...location}
|
||||
// As such, they are copied here
|
||||
const keysToCopy = ["speed", "accuracy", "altitude", "altitudeAccuracy", "heading"]
|
||||
this.geolocationState.currentGPSLocation.addCallbackAndRun((location) => {
|
||||
if (location === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
const feature = <Feature>{
|
||||
type: "Feature",
|
||||
properties: <GeoLocationPointProperties>{
|
||||
|
@ -156,6 +160,11 @@ export default class GeoLocationHandler {
|
|||
coordinates: [location.longitude, location.latitude],
|
||||
},
|
||||
}
|
||||
for (const key of keysToCopy) {
|
||||
if (location[key] !== null) {
|
||||
feature.properties[key] = location[key]
|
||||
}
|
||||
}
|
||||
|
||||
features.setData([feature])
|
||||
})
|
||||
|
|
|
@ -164,6 +164,11 @@ export abstract class OsmObject {
|
|||
})
|
||||
}
|
||||
|
||||
public static DownloadHistory(id: NodeId): UIEventSource<OsmNode[]>
|
||||
public static DownloadHistory(id: WayId): UIEventSource<OsmWay[]>
|
||||
public static DownloadHistory(id: RelationId): UIEventSource<OsmRelation[]>
|
||||
|
||||
public static DownloadHistory(id: OsmId): UIEventSource<OsmObject[]>
|
||||
public static DownloadHistory(id: string): UIEventSource<OsmObject[]> {
|
||||
if (OsmObject.historyCache.has(id)) {
|
||||
return OsmObject.historyCache.get(id)
|
||||
|
@ -181,6 +186,7 @@ export abstract class OsmObject {
|
|||
const osmObjects: OsmObject[] = []
|
||||
for (const element of elements) {
|
||||
let osmObject: OsmObject = null
|
||||
element.nodes = []
|
||||
switch (type) {
|
||||
case "node":
|
||||
osmObject = new OsmNode(idN)
|
||||
|
|
|
@ -324,16 +324,9 @@ export default class SimpleMetaTaggers {
|
|||
},
|
||||
})
|
||||
|
||||
Object.defineProperty(feature.properties, "_surface:ha", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
get: () => {
|
||||
const sqMeters = GeoOperations.surfaceAreaInSqMeters(feature)
|
||||
const sqMetersHa = "" + Math.floor(sqMeters / 1000) / 10
|
||||
delete feature.properties["_surface:ha"]
|
||||
feature.properties["_surface:ha"] = sqMetersHa
|
||||
return sqMetersHa
|
||||
},
|
||||
Utils.AddLazyProperty(feature.properties, "_surface:ha", () => {
|
||||
const sqMeters = GeoOperations.surfaceAreaInSqMeters(feature)
|
||||
return "" + Math.floor(sqMeters / 1000) / 10
|
||||
})
|
||||
|
||||
return true
|
||||
|
|
|
@ -25,6 +25,10 @@ export class RegexTag extends TagsFilter {
|
|||
if (typeof possibleRegex === "string") {
|
||||
return fromTag === possibleRegex
|
||||
}
|
||||
if (typeof fromTag.match !== "function") {
|
||||
console.error("Error: fromTag is not a regex: ", fromTag, possibleRegex)
|
||||
throw "Error: fromTag is not a regex: " + fromTag + possibleRegex
|
||||
}
|
||||
return fromTag.match(possibleRegex) !== null
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue