Skip to content

Commit

Permalink
Improve handling of OSM returned data
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM committed Jun 16, 2024
1 parent 7630f87 commit 687b0e1
Showing 1 changed file with 149 additions and 1 deletion.
150 changes: 149 additions & 1 deletion IsraelHiking.Web/src/application/services/poi.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,147 @@ export class PoiService {
if (poi.properties.poiIconColor && poi.properties.poiIcon && poi.properties.poiCategory) {
return;
}
if (feature.properties.class === "place") {
if (feature.properties.boundary === "protected_area" ||
feature.properties.boundary === "national_park" ||
feature.properties.leisure === "nature_reserve") {
poi.properties.poiIconColor = "#008000";
poi.properties.poiIcon = "icon-nature-reserve";
poi.properties.poiCategory = "Other";
return;
}
if (feature.properties.historic) {
poi.properties.poiIconColor = "#666666";
poi.properties.poiCategory = "Historic";
switch (feature.properties.historic) {
case "ruins":
poi.properties.poiIcon = "icon-ruins";
return;
case "archaeological_site":
poi.properties.poiIcon = "icon-archaeological";
return;
case "memorial":
case "monument":
poi.properties.poiIcon = "icon-memorial";
return;
}
}
if (feature.properties.leisure === "picnic_table" ||
feature.properties.tourism === "picnic_site" ||
feature.properties.amenity === "picnic") {
poi.properties.poiIconColor = "#734a08";
poi.properties.poiIcon = "icon-picnic";
poi.properties.poiCategory = "Camping";
}

if (feature.properties.natural) {
switch (feature.properties.natural) {
case "cave_entrance":
poi.properties.poiIconColor = "black";
poi.properties.poiIcon = "icon-cave";
poi.properties.poiCategory = "Natural";
return;
case "spring":
poi.properties.poiIconColor = "blue";
poi.properties.poiIcon = "icon-tint";
poi.properties.poiCategory = "Water";
return;
case "tree":
poi.properties.poiIconColor = "#008000";
poi.properties.poiIcon = "icon-tree";
poi.properties.poiCategory = "Natural";
return;
case "flowers":
poi.properties.poiIconColor = "#008000";
poi.properties.poiIcon = "icon-flowers";
poi.properties.poiCategory = "Natural";
return;
case "waterhole":
poi.properties.poiIconColor = "blue";
poi.properties.poiIcon = "icon-waterhole";
poi.properties.poiCategory = "Water";
return;
}
}

if (feature.properties.water === "reservoir" ||
feature.properties.water === "pond") {
poi.properties.poiIconColor = "blue";
poi.properties.poiIcon = "icon-tint";
poi.properties.poiCategory = "Water";
return;
}

if (feature.properties.man_made) {
poi.properties.poiIconColor = "blue";
poi.properties.poiCategory = "Water";
switch (feature.properties.man_made) {
case "water_well":
poi.properties.poiIcon = "icon-water-well";
return;
case "cistern":
poi.properties.poiIcon = "icon-cistern";
return;
}
}

if (feature.properties.waterway === "waterfall") {
poi.properties.poiIconColor = "blue";
poi.properties.poiIcon = "icon-waterfall";
poi.properties.poiCategory = "Water";
return;
}

if (feature.properties.place) {
poi.properties.poiIconColor = "black";
poi.properties.poiIcon = "icon-home";
poi.properties.poiCategory = "Wikipedia";
return;
}

if (feature.properties.tourism) {
switch (feature.properties.tourism) {
case "viewpoint":
poi.properties.poiIconColor = "#008000";
poi.properties.poiIcon = "icon-viewpoint";
poi.properties.poiCategory = "Viewpoint";
return;
case "picnic_site":
poi.properties.poiIconColor = "#734a08";
poi.properties.poiIcon = "icon-picnic";
poi.properties.poiCategory = "Camping";
return;
case "camp_site":
poi.properties.poiIconColor = "#734a08";
poi.properties.poiIcon = "icon-campsite";
poi.properties.poiCategory = "Camping";
return;
case "attraction":
poi.properties.poiIconColor = "#ffb800";
poi.properties.poiIcon = "icon-star";
poi.properties.poiCategory = "Other";
return;
}
return;
}

if (feature.properties.wikidata || feature.properties.wikipedia) {
poi.properties.poiIconColor = "black";
poi.properties.poiIcon = "icon-wikipedia-w";
poi.properties.poiCategory = "Wikipedia";
return;
}

if (feature.properties.natural === "peak") {
poi.properties.poiIconColor = "black";
poi.properties.poiIcon = "icon-peak";
poi.properties.poiCategory = "Other";
return;
}

poi.properties.poiIconColor = "black";
poi.properties.poiIcon = "icon-search";
poi.properties.poiCategory = "Other";

switch (feature.properties.subclass) {
case "spring":
case "pond":
Expand Down Expand Up @@ -396,6 +531,19 @@ export class PoiService {
lon: (bounds.northEast.lng + bounds.southWest.lng) / 2,
};
}
case "MultiPolygon": {
// HM TODO: this is a very rough approximation
const bounds = SpatialService.getBoundsForFeature(feature);
return {
lat: (bounds.northEast.lat + bounds.southWest.lat) / 2,
lon: (bounds.northEast.lng + bounds.southWest.lng) / 2,
};
}
case "MultiLineString":
return {
lat: feature.geometry.coordinates[0][0][1],
lon: feature.geometry.coordinates[0][0][0],
};
default:
throw new Error("Unsupported geometry type: " + feature.geometry.type);
}
Expand Down

0 comments on commit 687b0e1

Please sign in to comment.