Fix: use api.openstreetmap.org on many places, fix #1573

This commit is contained in:
Pieter Vander Vennet 2023-09-21 00:25:04 +02:00
parent 1930f7bb53
commit 8fccf78478
14 changed files with 36 additions and 35 deletions

View file

@ -1,6 +1,6 @@
{
"name": "mapcomplete",
"version": "0.33.0",
"version": "0.33.1",
"repository": "https://github.com/pietervdvn/MapComplete",
"description": "A small website to edit OSM easily",
"bugs": "https://github.com/pietervdvn/MapComplete/issues",
@ -21,13 +21,13 @@
"#": "This client_id is registered by 'Pieter Vander Vennet' on OSM.org",
"oauth_client_id": "sa1ngLJBJ8McmzHElN8NYtIDm5TZTYEYhq3-0snO4Qc",
"oauth_secret": "XU_cD5Mvw9VKk9T0t_gO8V7cbRC4Hmw2Tb4Rv0Zmz-U",
"url": "https://www.openstreetmap.org"
"url": "https://api.openstreetmap.org"
},
"osm": {
"#": "This client-id is registered by 'MapComplete' on osm.org",
"oauth_client_id": "K93H1d8ve7p-tVLE1ZwsQ4lAFLQk8INx5vfTLMu5DWk",
"oauth_secret": "NBWGhWDrD3QDB35xtVuxv4aExnmIt4FA_WgeLtwxasg",
"url": "https://www.openstreetmap.org"
"url": "https://api.openstreetmap.org"
},
"osm-test": {
"oauth_client_id": "HwUn6GPxGm1m9WwMarxTglhy6dBTM4YkaV1I9h6pDGU",

View file

@ -20,7 +20,7 @@ export default class OsmFeatureSource extends FeatureSourceMerger {
private options: {
bounds: Store<BBox>
readonly allowedFeatures: TagsFilter
backend?: "https://openstreetmap.org/" | string
backend?: "https://api.openstreetmap.org/" | string
/**
* If given: this featureSwitch will not update if the store contains 'false'
*/
@ -41,7 +41,7 @@ export default class OsmFeatureSource extends FeatureSourceMerger {
constructor(options: {
bounds: Store<BBox>
readonly allowedFeatures: TagsFilter
backend?: "https://openstreetmap.org/" | string
backend?: "https://api.openstreetmap.org/" | string
/**
* If given: this featureSwitch will not update if the store contains 'false'
*/
@ -54,7 +54,7 @@ export default class OsmFeatureSource extends FeatureSourceMerger {
this._bounds = options.bounds
this.allowedTags = options.allowedFeatures
this.isActive = options.isActive ?? new ImmutableStore(true)
this._backend = options.backend ?? "https://www.openstreetmap.org"
this._backend = options.backend ?? "https://api.openstreetmap.org"
this._bounds.addCallbackAndRunD((bbox) => this.loadData(bbox))
this._patchRelations = options?.patchRelations ?? true
}

View file

@ -215,7 +215,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr
throw "Invalid ID to conflate: " + this.wayToReplaceId
}
const url = `${
this.state.osmConnection?._oauth_config?.url ?? "https://openstreetmap.org"
this.state.osmConnection?._oauth_config?.url ?? "https://api.openstreetmap.org"
}/api/0.6/${this.wayToReplaceId}/full`
const rawData = await Utils.downloadJsonCached(url, 1000)
parsed = OsmObject.ParseObjects(rawData.elements)

View file

@ -85,7 +85,7 @@ export class OsmConnection {
this._oauth_config = {
oauth_client_id: import.meta.env.VITE_OSM_OAUTH_CLIENT_ID,
oauth_secret: import.meta.env.VITE_OSM_OAUTH_SECRET,
url: "https://www.openstreetmap.org",
url: "https://api.openstreetmap.org",
}
}
@ -179,7 +179,7 @@ export class OsmConnection {
/**
* The backend host, without path or trailing '/'
*
* new OsmConnection().Backend() // => "https://www.openstreetmap.org"
* new OsmConnection().Backend() // => "https://api.openstreetmap.org"
*/
public Backend(): string {
return this._oauth_config.url
@ -365,7 +365,6 @@ export class OsmConnection {
)
})
}
const auth = this.auth
const content = { lat, lon, text }
const response = await this.post("notes.json", JSON.stringify(content), {
"Content-Type": "application/json",
@ -414,7 +413,6 @@ export class OsmConnection {
'"\r\nContent-Type: application/gpx+xml',
}
const auth = this.auth
const boundary = "987654"
let body = ""

View file

@ -5,7 +5,7 @@ import OsmToGeoJson from "osmtogeojson"
import { Feature, LineString, Polygon } from "geojson"
export abstract class OsmObject {
private static defaultBackend = "https://www.openstreetmap.org/"
private static defaultBackend = "https://api.openstreetmap.org/"
protected static backendURL = OsmObject.defaultBackend
private static polygonFeatures = OsmObject.constructPolygonFeatures()
type: "node" | "way" | "relation"

View file

@ -17,7 +17,7 @@ export default class OsmObjectDownloader {
private historyCache = new Map<string, UIEventSource<OsmObject[]>>()
constructor(
backend: string = "https://www.openstreetmap.org",
backend: string = "https://api.openstreetmap.org",
changes?: {
readonly pendingChanges: UIEventSource<ChangeDescription[]>
readonly isUploading: Store<boolean>

View file

@ -219,7 +219,7 @@ class RewriteMetaInfoTags extends SimpleMetaTagger {
move("changeset", "_last_edit:changeset")
move("timestamp", "_last_edit:timestamp")
move("version", "_version_number")
feature.properties._backend = feature.properties._backend ?? "https://openstreetmap.org"
feature.properties._backend = feature.properties._backend ?? "https://api.openstreetmap.org"
return movedSomething
}
}

View file

@ -41,7 +41,7 @@ export default class NoteCommentElement extends Combine {
let userinfo = Stores.FromPromise(
Utils.downloadJsonCached(
"https://www.openstreetmap.org/api/0.6/user/" + comment.uid,
"https://api.openstreetmap.org/api/0.6/user/" + comment.uid,
24 * 60 * 60 * 1000
)
)

View file

@ -27,6 +27,9 @@ Note that these values can be prepare with javascript in the theme by using a [c
public static readonly imageExtensions = new Set(["jpg", "png", "svg", "jpeg", ".gif"])
public static initDomPurify() {
if (Utils.runningFromConsole) {
return
}
DOMPurify.addHook("afterSanitizeAttributes", function (node) {
// set all elements owning target to target=_blank + add noopener noreferrer
if ("target" in node) {

View file

@ -21,7 +21,7 @@ const latestTags = {
"public_bookcase:type": "reading_box",
}
Utils.injectJsonDownloadForTests("https://www.openstreetmap.org/api/0.6/node/5568693115", {
Utils.injectJsonDownloadForTests("https://api.openstreetmap.org/api/0.6/node/5568693115", {
version: "0.6",
generator: "CGImap 0.8.5 (1815943 spike-06.openstreetmap.org)",
copyright: "OpenStreetMap and contributors",

View file

@ -11,7 +11,7 @@ import { ImmutableStore } from "../../../../src/Logic/UIEventSource"
import { OsmConnection } from "../../../../src/Logic/Osm/OsmConnection"
describe("RelationSplitHandler", () => {
Utils.injectJsonDownloadForTests("https://www.openstreetmap.org/api/0.6/node/1124134958/ways", {
Utils.injectJsonDownloadForTests("https://api.openstreetmap.org/api/0.6/node/1124134958/ways", {
version: "0.6",
generator: "CGImap 0.8.5 (2937646 spike-07.openstreetmap.org)",
copyright: "OpenStreetMap and contributors",
@ -81,7 +81,7 @@ describe("RelationSplitHandler", () => {
})
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/relation/9572808/full",
"https://api.openstreetmap.org/api/0.6/relation/9572808/full",
{
version: "0.6",
generator: "CGImap 0.8.5 (3128319 spike-07.openstreetmap.org)",
@ -200,7 +200,7 @@ describe("RelationSplitHandler", () => {
}
)
Utils.injectJsonDownloadForTests("https://www.openstreetmap.org/api/0.6/way/687866206/full", {
Utils.injectJsonDownloadForTests("https://api.openstreetmap.org/api/0.6/way/687866206/full", {
version: "0.6",
generator: "CGImap 0.8.5 (2601512 spike-07.openstreetmap.org)",
copyright: "OpenStreetMap and contributors",
@ -250,7 +250,7 @@ describe("RelationSplitHandler", () => {
],
})
Utils.injectJsonDownloadForTests("https://www.openstreetmap.org/api/0.6/way/690497698/full", {
Utils.injectJsonDownloadForTests("https://api.openstreetmap.org/api/0.6/way/690497698/full", {
version: "0.6",
generator: "CGImap 0.8.5 (3023311 spike-07.openstreetmap.org)",
copyright: "OpenStreetMap and contributors",
@ -311,7 +311,7 @@ describe("RelationSplitHandler", () => {
],
})
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/relation/4374576/full",
"https://api.openstreetmap.org/api/0.6/relation/4374576/full",
{
version: "0.6",
generator: "CGImap 0.8.5 (1266692 spike-06.openstreetmap.org)",
@ -342,7 +342,7 @@ describe("RelationSplitHandler", () => {
}
)
Utils.injectJsonDownloadForTests("https://www.openstreetmap.org/api/0.6/way/143298912/full", {
Utils.injectJsonDownloadForTests("https://api.openstreetmap.org/api/0.6/way/143298912/full", {
version: "0.6",
generator: "CGImap 0.8.5 (4046166 spike-07.openstreetmap.org)",
copyright: "OpenStreetMap and contributors",

View file

@ -327,7 +327,7 @@ describe("ReplaceGeometryAction", () => {
const wayId = "way/160909312"
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/map.json?bbox=3.2166673243045807,51.21467321525788,3.217007964849472,51.21482442824023",
"https://api.openstreetmap.org/api/0.6/map.json?bbox=3.2166673243045807,51.21467321525788,3.217007964849472,51.21482442824023",
{
version: "0.6",
generator: "CGImap 0.8.6 (1549677 spike-06.openstreetmap.org)",
@ -715,7 +715,7 @@ describe("ReplaceGeometryAction", () => {
}
)
Utils.injectJsonDownloadForTests("https://www.openstreetmap.org/api/0.6/way/160909312/full", {
Utils.injectJsonDownloadForTests("https://api.openstreetmap.org/api/0.6/way/160909312/full", {
version: "0.6",
generator: "CGImap 0.8.6 (2407324 spike-06.openstreetmap.org)",
copyright: "OpenStreetMap and contributors",
@ -880,7 +880,7 @@ describe("ReplaceGeometryAction", () => {
[3.2166673243045807, 51.21467321525788],
[3.217007964849472, 51.21482442824023],
])
const url = `https://www.openstreetmap.org/api/0.6/map.json?bbox=${bbox.minLon},${bbox.minLat},${bbox.maxLon},${bbox.maxLat}`
const url = `https://api.openstreetmap.org/api/0.6/map.json?bbox=${bbox.minLon},${bbox.minLat},${bbox.maxLon},${bbox.maxLat}`
const data = await Utils.downloadJson(url)
const fullNodeDatabase = new FullNodeDatabaseSource()
fullNodeDatabase.handleOsmJson(data, 0, 0, 0)

View file

@ -9,7 +9,7 @@ describe("SplitAction", () => {
{
// Setup of download
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/way/941079939/full",
"https://api.openstreetmap.org/api/0.6/way/941079939/full",
{
version: "0.6",
generator: "CGImap 0.8.5 (957273 spike-08.openstreetmap.org)",
@ -210,7 +210,7 @@ describe("SplitAction", () => {
)
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/way/941079939/relations",
"https://api.openstreetmap.org/api/0.6/way/941079939/relations",
{
version: "0.6",
generator: "CGImap 0.8.5 (2419440 spike-07.openstreetmap.org)",
@ -222,7 +222,7 @@ describe("SplitAction", () => {
)
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/way/295132739/full",
"https://api.openstreetmap.org/api/0.6/way/295132739/full",
{
version: "0.6",
generator: "CGImap 0.8.5 (3138407 spike-07.openstreetmap.org)",
@ -409,7 +409,7 @@ describe("SplitAction", () => {
}
)
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/way/295132739/relations",
"https://api.openstreetmap.org/api/0.6/way/295132739/relations",
// Mimick that there are no relations relation is missing
{
version: "0.6",
@ -422,7 +422,7 @@ describe("SplitAction", () => {
)
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/way/61435323/full",
"https://api.openstreetmap.org/api/0.6/way/61435323/full",
{
version: "0.6",
generator: "CGImap 0.8.5 (53092 spike-08.openstreetmap.org)",
@ -488,7 +488,7 @@ describe("SplitAction", () => {
}
)
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/way/61435323/relations",
"https://api.openstreetmap.org/api/0.6/way/61435323/relations",
{
version: "0.6",
generator: "CGImap 0.8.5 (3622541 spike-06.openstreetmap.org)",
@ -2567,7 +2567,7 @@ describe("SplitAction", () => {
}
)
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/way/61435332/full",
"https://api.openstreetmap.org/api/0.6/way/61435332/full",
{
version: "0.6",
generator: "CGImap 0.8.5 (3819319 spike-06.openstreetmap.org)",
@ -2620,7 +2620,7 @@ describe("SplitAction", () => {
}
)
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/way/509668834/full",
"https://api.openstreetmap.org/api/0.6/way/509668834/full",
{
version: "0.6",
generator: "CGImap 0.8.5 (3735280 spike-06.openstreetmap.org)",

View file

@ -8,7 +8,7 @@ import OsmObjectDownloader from "../../../src/Logic/Osm/OsmObjectDownloader"
describe("OsmObject", () => {
describe("download referencing ways", () => {
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/node/1124134958/ways",
"https://api.openstreetmap.org/api/0.6/node/1124134958/ways",
{
version: "0.6",
generator: "CGImap 0.8.6 (49805 spike-06.openstreetmap.org)",
@ -89,7 +89,7 @@ describe("OsmObject", () => {
it("should download full OSM-relations", async () => {
ScriptUtils.fixUtils()
Utils.injectJsonDownloadForTests(
"https://www.openstreetmap.org/api/0.6/relation/5759328/full",
"https://api.openstreetmap.org/api/0.6/relation/5759328/full",
JSON.parse(readFileSync("./test/data/relation_5759328.json", { encoding: "utf-8" }))
)
const r = await new OsmObjectDownloader()