diff --git a/IsraelHiking.Web/src/application/application.module.ts b/IsraelHiking.Web/src/application/application.module.ts index 970fba373..97088cb21 100644 --- a/IsraelHiking.Web/src/application/application.module.ts +++ b/IsraelHiking.Web/src/application/application.module.ts @@ -97,6 +97,7 @@ import { OverpassTurboService } from "./services/overpass-turbo.service"; import { ImageAttributionService } from "./services/image-attribution.service"; import { PmTilesService } from "./services/pmtiles.service"; import { ApplicationUpdateService } from "./services/application-update.service"; +import { INatureService } from "./services/inature.service"; // interactions import { RouteEditPoiInteraction } from "./components/intercations/route-edit-poi.interaction"; import { RouteEditRouteInteraction } from "./components/intercations/route-edit-route.interaction"; @@ -309,6 +310,7 @@ const initializeApplication = (injector: Injector) => async () => { ImageAttributionService, PmTilesService, ApplicationUpdateService, + INatureService, AudioPlayerFactory, FileSystemWrapper, // eslint-disable-next-line diff --git a/IsraelHiking.Web/src/application/services/iNature.service.ts b/IsraelHiking.Web/src/application/services/iNature.service.ts index 2d545ae4c..9735f4f30 100644 --- a/IsraelHiking.Web/src/application/services/iNature.service.ts +++ b/IsraelHiking.Web/src/application/services/iNature.service.ts @@ -24,7 +24,7 @@ export class INatureService { } }; const lngLat = this.setLocation(content, feature); - this.setImageAndWebsite(content, feature, pageId); + this.setImageAndWebsite(content, feature, title); feature.geometry = await this.getGeometryFromContent(content) ?? { type: "Point", coordinates: [lngLat.lng, lngLat.lat] @@ -90,13 +90,17 @@ export class INatureService { } private async getGeometryFromContent(content: string): Promise { - const shareRegexp = new RegExp("israelhiking\.osm\.org\.il/share/(.*?)"); + const shareRegexp = new RegExp("israelhiking\\.osm\\.org\\.il/share/(.*?)[\"']"); const match = content.match(shareRegexp); if (match == null) { return null; } const shareId = match[1]; - const geojson = await firstValueFrom(this.httpClient.get(`${Urls.urls}${shareId}?format=geojson`)) as GeoJSON.FeatureCollection; - return geojson.features.find(f => f.geometry.type === "LineString")?.geometry; + // HM TODO: replace this: + //let url = Urls.urls + shareId + "?format=geojson"; + const url = "https://israelhiking.osm.org.il/api/urls/" + shareId + "?format=geojson"; + const geojson = await firstValueFrom(this.httpClient.get(url)) as GeoJSON.FeatureCollection; + console.log(geojson); + return geojson.features.find(f => f.geometry.type !== "Point")?.geometry; } } \ No newline at end of file