forked from MapComplete/MapComplete
Auto-formatting
This commit is contained in:
parent
9e000d521f
commit
fed4cff878
26 changed files with 360 additions and 304 deletions
|
@ -210,8 +210,8 @@ export default class OverpassFeatureSource implements FeatureSource {
|
|||
if (overpass === undefined) {
|
||||
return undefined
|
||||
}
|
||||
this.runningQuery.setData(true);
|
||||
[data, date] = await overpass.queryGeoJson(bounds)
|
||||
this.runningQuery.setData(true)
|
||||
;[data, date] = await overpass.queryGeoJson(bounds)
|
||||
} catch (e) {
|
||||
self.retries.data++
|
||||
self.retries.ping()
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* This actor will download the latest version of the selected element from OSM and update the tags if necessary.
|
||||
*/
|
||||
import {UIEventSource} from "../UIEventSource"
|
||||
import {ElementStorage} from "../ElementStorage"
|
||||
import {Changes} from "../Osm/Changes"
|
||||
import {OsmObject} from "../Osm/OsmObject"
|
||||
import {OsmConnection} from "../Osm/OsmConnection"
|
||||
import { UIEventSource } from "../UIEventSource"
|
||||
import { ElementStorage } from "../ElementStorage"
|
||||
import { Changes } from "../Osm/Changes"
|
||||
import { OsmObject } from "../Osm/OsmObject"
|
||||
import { OsmConnection } from "../Osm/OsmConnection"
|
||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"
|
||||
import SimpleMetaTagger from "../SimpleMetaTagger"
|
||||
|
||||
|
@ -59,17 +59,16 @@ export default class SelectedElementTagsUpdater {
|
|||
return
|
||||
}
|
||||
try {
|
||||
|
||||
const latestTags = await OsmObject.DownloadPropertiesOf(id)
|
||||
if (latestTags === "deleted") {
|
||||
console.warn("The current selected element has been deleted upstream!")
|
||||
const currentTagsSource = state.allElements.getEventSourceById(id)
|
||||
if(currentTagsSource.data["_deleted"] === "yes"){
|
||||
if (currentTagsSource.data["_deleted"] === "yes") {
|
||||
return
|
||||
}
|
||||
currentTagsSource.data["_deleted"] = "yes"
|
||||
currentTagsSource.ping()
|
||||
return;
|
||||
return
|
||||
}
|
||||
SelectedElementTagsUpdater.applyUpdate(state, latestTags, id)
|
||||
console.log("Updated", id)
|
||||
|
|
|
@ -85,7 +85,7 @@ export default class FilteringFeatureSource implements FeatureSourceForLayer, Ti
|
|||
if (isShown !== undefined && !isShown.matchesProperties(tags)) {
|
||||
return false
|
||||
}
|
||||
if(tags._deleted === "yes"){
|
||||
if (tags._deleted === "yes") {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* This feature source helps the ShowDataLayer class: it introduces the necessary extra features and indicates with what renderConfig it should be rendered.
|
||||
*/
|
||||
import {Store} from "../../UIEventSource"
|
||||
import {GeoOperations} from "../../GeoOperations"
|
||||
import { Store } from "../../UIEventSource"
|
||||
import { GeoOperations } from "../../GeoOperations"
|
||||
import FeatureSource from "../FeatureSource"
|
||||
import PointRenderingConfig from "../../../Models/ThemeConfig/PointRenderingConfig"
|
||||
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
|
||||
|
@ -17,7 +17,10 @@ export default class RenderingMultiPlexerFeatureSource {
|
|||
>
|
||||
private readonly pointRenderings: { rendering: PointRenderingConfig; index: number }[]
|
||||
private readonly centroidRenderings: { rendering: PointRenderingConfig; index: number }[]
|
||||
private readonly projectedCentroidRenderings: { rendering: PointRenderingConfig; index: number }[]
|
||||
private readonly projectedCentroidRenderings: {
|
||||
rendering: PointRenderingConfig
|
||||
index: number
|
||||
}[]
|
||||
private readonly startRenderings: { rendering: PointRenderingConfig; index: number }[]
|
||||
private readonly endRenderings: { rendering: PointRenderingConfig; index: number }[]
|
||||
private readonly hasCentroid: boolean
|
||||
|
@ -90,10 +93,15 @@ export default class RenderingMultiPlexerFeatureSource {
|
|||
}
|
||||
} else if (feat.geometry.type === "MultiPolygon") {
|
||||
if (this.centroidRenderings.length > 0 || this.projectedCentroidRenderings.length > 0) {
|
||||
|
||||
const centerpoints: [number, number][] = (<[number, number][][][]>feat.geometry.coordinates).map(rings => GeoOperations.centerpointCoordinates(
|
||||
{type: "Feature", properties: {}, geometry: {type: "Polygon", coordinates: rings}}
|
||||
))
|
||||
const centerpoints: [number, number][] = (<[number, number][][][]>(
|
||||
feat.geometry.coordinates
|
||||
)).map((rings) =>
|
||||
GeoOperations.centerpointCoordinates({
|
||||
type: "Feature",
|
||||
properties: {},
|
||||
geometry: { type: "Polygon", coordinates: rings },
|
||||
})
|
||||
)
|
||||
for (const centroidRendering of this.centroidRenderings) {
|
||||
for (const centerpoint of centerpoints) {
|
||||
addAsPoint(feat, centroidRendering, centerpoint)
|
||||
|
@ -105,8 +113,6 @@ export default class RenderingMultiPlexerFeatureSource {
|
|||
addAsPoint(feat, centroidRendering, centerpoint)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// AT last, add it 'as is' to what we should render
|
||||
|
@ -116,7 +122,6 @@ export default class RenderingMultiPlexerFeatureSource {
|
|||
lineRenderingIndex: i,
|
||||
})
|
||||
}
|
||||
|
||||
} else {
|
||||
// This is a a line or polygon: add the centroids
|
||||
let centerpoint: [number, number] = undefined
|
||||
|
|
|
@ -19,9 +19,9 @@ export default class UserDetails {
|
|||
public totalMessages: number = 0
|
||||
public home: { lon: number; lat: number }
|
||||
public backend: string
|
||||
public account_created: string;
|
||||
public tracesCount: number = 0;
|
||||
public description: string;
|
||||
public account_created: string
|
||||
public tracesCount: number = 0
|
||||
public description: string
|
||||
|
||||
constructor(backend: string) {
|
||||
this.backend = backend
|
||||
|
@ -214,8 +214,12 @@ export class OsmConnection {
|
|||
data.name = userInfo.getAttribute("display_name")
|
||||
data.account_created = userInfo.getAttribute("account_created")
|
||||
data.uid = Number(userInfo.getAttribute("id"))
|
||||
data.csCount = Number.parseInt( userInfo.getElementsByTagName("changesets")[0].getAttribute("count") ?? 0)
|
||||
data.tracesCount = Number.parseInt( userInfo.getElementsByTagName("changesets")[0].getAttribute("count") ?? 0)
|
||||
data.csCount = Number.parseInt(
|
||||
userInfo.getElementsByTagName("changesets")[0].getAttribute("count") ?? 0
|
||||
)
|
||||
data.tracesCount = Number.parseInt(
|
||||
userInfo.getElementsByTagName("changesets")[0].getAttribute("count") ?? 0
|
||||
)
|
||||
|
||||
data.img = undefined
|
||||
const imgEl = userInfo.getElementsByTagName("img")
|
||||
|
|
|
@ -71,7 +71,7 @@ export abstract class OsmObject {
|
|||
const url = `${OsmObject.backendURL}api/0.6/${id}`
|
||||
const rawData = await Utils.downloadJsonCachedAdvanced(url, 1000)
|
||||
console.log(rawData)
|
||||
if(rawData["error"] !== undefined && rawData["statuscode"] === 410){
|
||||
if (rawData["error"] !== undefined && rawData["statuscode"] === 410) {
|
||||
return "deleted"
|
||||
}
|
||||
return rawData["contents"].elements[0].tags
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
import UserRelatedState from "./UserRelatedState"
|
||||
import {Store, Stores, UIEventSource} from "../UIEventSource"
|
||||
import { Store, Stores, UIEventSource } from "../UIEventSource"
|
||||
import BaseLayer from "../../Models/BaseLayer"
|
||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"
|
||||
import AvailableBaseLayers from "../Actors/AvailableBaseLayers"
|
||||
import Attribution from "../../UI/BigComponents/Attribution"
|
||||
import Minimap, {MinimapObj} from "../../UI/Base/Minimap"
|
||||
import {Tiles} from "../../Models/TileRange"
|
||||
import Minimap, { MinimapObj } from "../../UI/Base/Minimap"
|
||||
import { Tiles } from "../../Models/TileRange"
|
||||
import BaseUIElement from "../../UI/BaseUIElement"
|
||||
import FilteredLayer, {FilterState} from "../../Models/FilteredLayer"
|
||||
import FilteredLayer, { FilterState } from "../../Models/FilteredLayer"
|
||||
import TilesourceConfig from "../../Models/ThemeConfig/TilesourceConfig"
|
||||
import {QueryParameters} from "../Web/QueryParameters"
|
||||
import { QueryParameters } from "../Web/QueryParameters"
|
||||
import ShowOverlayLayer from "../../UI/ShowDataLayer/ShowOverlayLayer"
|
||||
import {FeatureSourceForLayer, Tiled} from "../FeatureSource/FeatureSource"
|
||||
import { FeatureSourceForLayer, Tiled } from "../FeatureSource/FeatureSource"
|
||||
import SimpleFeatureSource from "../FeatureSource/Sources/SimpleFeatureSource"
|
||||
import {LocalStorageSource} from "../Web/LocalStorageSource"
|
||||
import {GeoOperations} from "../GeoOperations"
|
||||
import { LocalStorageSource } from "../Web/LocalStorageSource"
|
||||
import { GeoOperations } from "../GeoOperations"
|
||||
import TitleHandler from "../Actors/TitleHandler"
|
||||
import {BBox} from "../BBox"
|
||||
import { BBox } from "../BBox"
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||
import {TiledStaticFeatureSource} from "../FeatureSource/Sources/StaticFeatureSource"
|
||||
import {Translation, TypedTranslation} from "../../UI/i18n/Translation"
|
||||
import {Tag} from "../Tags/Tag"
|
||||
import {OsmConnection} from "../Osm/OsmConnection"
|
||||
import {Feature, LineString} from "geojson"
|
||||
import {OsmTags} from "../../Models/OsmFeature"
|
||||
import { TiledStaticFeatureSource } from "../FeatureSource/Sources/StaticFeatureSource"
|
||||
import { Translation, TypedTranslation } from "../../UI/i18n/Translation"
|
||||
import { Tag } from "../Tags/Tag"
|
||||
import { OsmConnection } from "../Osm/OsmConnection"
|
||||
import { Feature, LineString } from "geojson"
|
||||
import { OsmTags } from "../../Models/OsmFeature"
|
||||
|
||||
export interface GlobalFilter {
|
||||
filter: FilterState
|
||||
|
@ -266,27 +266,30 @@ export default class MapState extends UserRelatedState {
|
|||
this.currentUserLocation = new SimpleFeatureSource(gpsLayerDef, Tiles.tile_index(0, 0, 0))
|
||||
}
|
||||
|
||||
private initSelectedElement(){
|
||||
private initSelectedElement() {
|
||||
const layerDef: FilteredLayer = this.filteredLayers.data.filter(
|
||||
(l) => l.layerDef.id === "selected_element"
|
||||
)[0]
|
||||
const empty = []
|
||||
const store = this.selectedElement.map(feature => {
|
||||
if(feature === undefined || feature === null){
|
||||
const store = this.selectedElement.map((feature) => {
|
||||
if (feature === undefined || feature === null) {
|
||||
return empty
|
||||
}
|
||||
return [{
|
||||
feature: {
|
||||
type:"Feature",
|
||||
properties: {
|
||||
selected: "yes",
|
||||
id: "selected" + feature.properties.id
|
||||
return [
|
||||
{
|
||||
feature: {
|
||||
type: "Feature",
|
||||
properties: {
|
||||
selected: "yes",
|
||||
id: "selected" + feature.properties.id,
|
||||
},
|
||||
geometry: feature.geometry,
|
||||
},
|
||||
geometry:feature.geometry
|
||||
}
|
||||
, freshness: new Date()}];
|
||||
});
|
||||
this.selectedElementsLayer = new TiledStaticFeatureSource(store,layerDef);
|
||||
freshness: new Date(),
|
||||
},
|
||||
]
|
||||
})
|
||||
this.selectedElementsLayer = new TiledStaticFeatureSource(store, layerDef)
|
||||
}
|
||||
|
||||
private initUserLocationTrail() {
|
||||
|
|
|
@ -127,35 +127,38 @@ export default class MangroveReviews {
|
|||
this._lastUpdate = new Date()
|
||||
|
||||
const self = this
|
||||
mangrove.getReviews({ sub: this.GetSubjectUri() })
|
||||
mangrove
|
||||
.getReviews({ sub: this.GetSubjectUri() })
|
||||
.then((data) => {
|
||||
const reviews = []
|
||||
const reviewsByUser = []
|
||||
for (const review of data.reviews) {
|
||||
const r = review.payload
|
||||
const reviews = []
|
||||
const reviewsByUser = []
|
||||
for (const review of data.reviews) {
|
||||
const r = review.payload
|
||||
|
||||
console.log(
|
||||
"PublicKey is ",
|
||||
self._mangroveIdentity.kid.data,
|
||||
"reviews.kid is",
|
||||
review.kid
|
||||
)
|
||||
const byUser = self._mangroveIdentity.kid.map((data) => data === review.signature)
|
||||
const rev: Review = {
|
||||
made_by_user: byUser,
|
||||
date: new Date(r.iat * 1000),
|
||||
comment: r.opinion,
|
||||
author: r.metadata.nickname,
|
||||
affiliated: r.metadata.is_affiliated,
|
||||
rating: r.rating, // percentage points
|
||||
console.log(
|
||||
"PublicKey is ",
|
||||
self._mangroveIdentity.kid.data,
|
||||
"reviews.kid is",
|
||||
review.kid
|
||||
)
|
||||
const byUser = self._mangroveIdentity.kid.map(
|
||||
(data) => data === review.signature
|
||||
)
|
||||
const rev: Review = {
|
||||
made_by_user: byUser,
|
||||
date: new Date(r.iat * 1000),
|
||||
comment: r.opinion,
|
||||
author: r.metadata.nickname,
|
||||
affiliated: r.metadata.is_affiliated,
|
||||
rating: r.rating, // percentage points
|
||||
}
|
||||
|
||||
;(rev.made_by_user ? reviewsByUser : reviews).push(rev)
|
||||
}
|
||||
|
||||
;(rev.made_by_user ? reviewsByUser : reviews).push(rev)
|
||||
}
|
||||
self._reviews.setData(reviewsByUser.concat(reviews))
|
||||
})
|
||||
.catch(e => {
|
||||
console.error("Could not download review for ", e);
|
||||
self._reviews.setData(reviewsByUser.concat(reviews))
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error("Could not download review for ", e)
|
||||
})
|
||||
return this._reviews
|
||||
}
|
||||
|
|
|
@ -147,8 +147,8 @@ export default class Wikipedia {
|
|||
},
|
||||
]
|
||||
}
|
||||
if(result["error"]){
|
||||
throw "Could not download: "+JSON.stringify(result)
|
||||
if (result["error"]) {
|
||||
throw "Could not download: " + JSON.stringify(result)
|
||||
}
|
||||
const el = document.createElement("html")
|
||||
el.innerHTML = result["content"].replace(/href="\//g, 'href="' + this.backend + "/")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue