Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Points of interest to use tiles #1979

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
cf404ca
Initial commit to move from indexdb and files to tiles
HarelM Feb 18, 2024
3db79cd
Merge branch 'main' into tile-pois
HarelM Mar 21, 2024
53b90b9
Update to use the new pois end point
HarelM Mar 21, 2024
2799840
Improve geometry and language and allow tests to run
HarelM Mar 21, 2024
3ba2dc3
Support place icon
HarelM Mar 21, 2024
2c1c79c
Fix lint, add offline support
HarelM Mar 22, 2024
f486ba5
Fix tests, remove unneeded field from state
HarelM Mar 22, 2024
0f1a933
Fix offline address for pmtiles.
HarelM Mar 22, 2024
47b970c
Fix typo which caused a crash
HarelM Mar 22, 2024
195a49b
Improve properties
HarelM Mar 28, 2024
e884d7f
Merge branch 'main' into tile-pois
HarelM Jun 2, 2024
1035658
For OSM elements - get the data from OSM and wikipedia.
HarelM Jun 4, 2024
e0d3831
Add support for external sources
HarelM Jun 8, 2024
5839060
Merge branch 'main' into tile-pois
HarelM Jun 8, 2024
965e40e
Fix poi source layer name
HarelM Jun 8, 2024
ea6d37b
Fix test
HarelM Jun 8, 2024
7630f87
fix lint
HarelM Jun 8, 2024
687b0e1
Improve handling of OSM returned data
HarelM Jun 16, 2024
1356427
Fix tomb, used cloudflare source.
HarelM Jun 16, 2024
dfb0315
Final fixes in links to points
HarelM Jun 16, 2024
32beed4
Fix lint
HarelM Jun 16, 2024
1b005ee
Fix tests
HarelM Jun 16, 2024
8add4ea
Merge branch 'main' into tile-pois
HarelM Jun 16, 2024
499ec8c
Merge branch 'main' into tile-pois
HarelM Jul 3, 2024
85c43e1
Adds the ability to merge ways with the same name
HarelM Jul 3, 2024
6bea090
Allow more distance between ways - 30 meters
HarelM Jul 3, 2024
e73d145
Merge branch 'main' into tile-pois
HarelM Jul 14, 2024
ffbbd51
Improve how places will look using overpass turbo
HarelM Jul 14, 2024
c102b16
Added trails pois source and relevant handling
HarelM Jul 14, 2024
dee57dd
Fix test
HarelM Jul 14, 2024
5bf0725
Improve location of none point POIs, fix missing image and source lin…
HarelM Jul 21, 2024
a5e36f0
Sort out mtb name related routes.
HarelM Jul 24, 2024
d27fddc
Added support for inature tag
HarelM Aug 8, 2024
c2b2200
Remove mtb_name, added improved line merge
HarelM Aug 11, 2024
6fa6fd2
Update inature reference according to discussion
HarelM Aug 11, 2024
80fa887
Merge branch 'main' into tile-pois
HarelM Aug 25, 2024
d2b15ee
Fix lint
HarelM Aug 25, 2024
9cef37a
Add iNature service to client side.
HarelM Sep 3, 2024
5482567
Fix initialization, Add iNature route support.
HarelM Sep 3, 2024
0a5d02d
Fix lint.
HarelM Sep 3, 2024
8d05f38
Use simplified regexp notation.
HarelM Sep 3, 2024
9f4624f
Make regexp case insensitive.
HarelM Sep 3, 2024
d0f8f2a
Rename iNature.service.ts to inature.service.ts
HarelM Sep 3, 2024
079cbe6
Merge branch 'main' into tile-pois
HarelM Sep 3, 2024
5cc36d7
Add logging
HarelM Sep 4, 2024
1ca49aa
Add wikidata service to present wikidata point online.
HarelM Sep 4, 2024
67b9c9f
Fix failure in test
HarelM Sep 4, 2024
1c6e212
Merge branch 'main' into tile-pois
HarelM Sep 17, 2024
57e09d8
Update package to use latest ngx-maplibre, use poi source from server.
HarelM Sep 17, 2024
5694d44
Fix hiking icon
HarelM Sep 18, 2024
17e906f
Add removal of duplicated points
HarelM Sep 20, 2024
52c038a
Merge branch 'main' into tile-pois
HarelM Sep 20, 2024
471b8aa
Merge branch 'main' into tile-pois
HarelM Sep 28, 2024
a9e2bcf
Fix issue with recording by upgrading the ngx-maplibre library
HarelM Sep 29, 2024
b07b168
Fix typos
HarelM Sep 30, 2024
7381361
Fix test due to deduplication code.
HarelM Sep 30, 2024
f3cd227
Remove zoom 10 limitation for POIs.
HarelM Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions IsraelHiking.Web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions IsraelHiking.Web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@mapbox/mapbox-gl-rtl-text": "0.2.3",
"@mapbox/polyline": "^1.2.1",
"@mapbox/vector-tile": "^1.3.1",
"@maplibre/ngx-maplibre-gl": "^18.0.0",
"@maplibre/ngx-maplibre-gl": "^18.1.2",
"@ng-idle/core": "^15.0.0",
"@ngxs/store": "^18.1.1",
"@nicky-lenaers/ngx-scroll-to": "^14.0.0",
Expand Down Expand Up @@ -72,7 +72,7 @@
"linear-interpolator": "^1.0.2",
"lodash-es": "^4.17.21",
"lottie-web": "^5.12.2",
"maplibre-gl": "^4.6.0",
"maplibre-gl": "^4.7.0",
"minisearch": "^7.1.0",
"ngx-infinite-scroll": "^18.0.0",
"ngx-lottie": "^12.0.0",
Expand Down
4 changes: 4 additions & 0 deletions IsraelHiking.Web/src/application/application.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ 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";
import { WikidataService } from "./services/wikidata.service";
// interactions
import { RouteEditPoiInteraction } from "./components/intercations/route-edit-poi.interaction";
import { RouteEditRouteInteraction } from "./components/intercations/route-edit-route.interaction";
Expand Down Expand Up @@ -309,6 +311,8 @@ const initializeApplication = (injector: Injector) => async () => {
ImageAttributionService,
PmTilesService,
ApplicationUpdateService,
INatureService,
WikidataService,
AudioPlayerFactory,
FileSystemWrapper,
// eslint-disable-next-line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { SpatialService } from "../../services/spatial.service";
import { NavigateHereService } from "../../services/navigate-here.service";
import { SetSelectedPoiAction } from "../../reducers/poi.reducer";
import { AddPrivatePoiAction } from "../../reducers/routes.reducer";
import { GeoJSONUtils } from "../../services/geojson-utils";
import type { ApplicationState, LatLngAlt, LinkData, Overlay } from "../../models/models";

@Component({
Expand All @@ -26,7 +27,7 @@ import type { ApplicationState, LatLngAlt, LinkData, Overlay } from "../../model
export class LayersViewComponent extends BaseMapComponent implements OnInit {
private static readonly MAX_MENU_POINTS_IN_CLUSTER = 7;

public poiGeoJsonData: GeoJSON.FeatureCollection<GeoJSON.Point>;
public poiGeoJsonData: GeoJSON.FeatureCollection<GeoJSON.Geometry>;
public selectedPoiFeature: GeoJSON.Feature<GeoJSON.Point>;
public selectedPoiGeoJson: Immutable<GeoJSON.FeatureCollection>;
public selectedCluster: GeoJSON.Feature<GeoJSON.Point>;
Expand Down Expand Up @@ -132,11 +133,11 @@ export class LayersViewComponent extends BaseMapComponent implements OnInit {
}

public getTitle(feature: GeoJSON.Feature<GeoJSON.Point>): string {
return this.poiService.getTitle(feature, this.resources.getCurrentLanguageCodeSimplified());
return GeoJSONUtils.getTitle(feature, this.resources.getCurrentLanguageCodeSimplified());
}

public hasExtraData(feature: GeoJSON.Feature<GeoJSON.Point>): boolean {
return this.poiService.hasExtraData(feature, this.resources.getCurrentLanguageCodeSimplified());
return GeoJSONUtils.hasExtraData(feature, this.resources.getCurrentLanguageCodeSimplified());
}

public isCoordinatesFeature(feature: Immutable<GeoJSON.Feature>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Router } from "@angular/router";

import { BaseMapComponent } from "../base-map.component";
import { ResourcesService } from "../../services/resources.service";
import { PoiService } from "../../services/poi.service";
import { RouteStrings } from "../../services/hash.service";
import { GeoJSONUtils } from "../../services/geojson-utils";

@Component({
selector: "cluster-overlay",
Expand All @@ -20,18 +20,17 @@ export class ClusterOverlayComponent extends BaseMapComponent {
public closed: EventEmitter<void>;

constructor(resources: ResourcesService,
private readonly router: Router,
private readonly poiService: PoiService) {
private readonly router: Router) {
super(resources);
this.closed = new EventEmitter();
}

public getTitle(feature: GeoJSON.Feature) {
return this.poiService.getTitle(feature, this.resources.getCurrentLanguageCodeSimplified());
return GeoJSONUtils.getTitle(feature, this.resources.getCurrentLanguageCodeSimplified());
}

public hasExtraData(feature: GeoJSON.Feature): boolean {
return this.poiService.hasExtraData(feature, this.resources.getCurrentLanguageCodeSimplified());
return GeoJSONUtils.hasExtraData(feature, this.resources.getCurrentLanguageCodeSimplified());
}

public clickOnItem(feature: GeoJSON.Feature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p class="w-full">{{resources.translate(categoriesGroup.type)}}</p>
</div>
<div class="w-1/5">
<button class="w-full !h-full" mat-button (click)="toggleVisibility($event)" angulartics2On="click" angularticsCategory="Layers" angularticsAction="Toggle visiblity of category layer {{categoriesGroup.type}}">
<button class="w-full !h-full" mat-button (click)="toggleVisibility($event)" angulartics2On="click" angularticsCategory="Layers" angularticsAction="Toggle visibility of category layer {{categoriesGroup.type}}">
<i class="fa fa-lg" [ngClass]="{'icon-eye': categoriesGroup.visible, 'icon-eye-slash': !categoriesGroup.visible}"></i>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</mat-expansion-panel-header>
<div *ngFor="let overlay of (overlays$ | async)">
<div class="flex flex-row">
<button mat-button class="row-button flex-1 !justify-start" (click)="toggleVisibility(overlay)" angulartics2On="click" angularticsCategory="Layers" angularticsAction="Toggle overlay visiblity {{overlay.key}}">
<button mat-button class="row-button flex-1 !justify-start" (click)="toggleVisibility(overlay)" angulartics2On="click" angularticsCategory="Layers" angularticsAction="Toggle overlay visibility {{overlay.key}}">
<span><i class="fa" [ngClass]="{'icon-eye': overlay.visible, 'icon-eye-slash': !overlay.visible}"></i></span>
<span class="break-all">{{resources.translate(overlay.key)}}</span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { GeoJsonParser } from "../../../services/geojson.parser";
import { sidebarAnimate } from "../sidebar.component";
import { AddRouteAction, AddPrivatePoiAction } from "../../../reducers/routes.reducer";
import { SetSelectedPoiAction, SetUploadMarkerDataAction, SetSidebarAction } from "../../../reducers/poi.reducer";
import { GeoJSONUtils } from "../../../services/geojson-utils";
import type {
LinkData,
LatLngAlt,
Expand Down Expand Up @@ -181,13 +182,13 @@ export class PublicPoiSidebarComponent extends BaseMapComponent implements OnDes

private initFromFeature(feature: GeoJSON.Feature) {
this.fullFeature = feature;
this.latlng = this.poiService.getLocation(feature);
this.latlng = GeoJSONUtils.getLocation(feature);
this.sourceImageUrls = this.getSourceImageUrls(feature);
this.shareLinks = this.poiService.getPoiSocialLinks(feature);
this.contribution = this.poiService.getContribution(feature);
this.info = this.poiService.getEditableDataFromFeature(feature);
const language = this.resources.getCurrentLanguageCodeSimplified();
this.titleService.set(this.poiService.getTitle(feature, language));
this.titleService.set(GeoJSONUtils.getTitle(feature, language));
}

private getSourceImageUrls(feature: GeoJSON.Feature): SourceImageUrlPair[] {
Expand Down Expand Up @@ -228,8 +229,8 @@ export class PublicPoiSidebarComponent extends BaseMapComponent implements OnDes
return "";
}
const language = this.resources.getCurrentLanguageCodeSimplified();
const description = this.poiService.getDescription(this.fullFeature, language) ||
this.poiService.getExternalDescription(this.fullFeature, language);
const description = GeoJSONUtils.getDescription(this.fullFeature, language) ||
GeoJSONUtils.getExternalDescription(this.fullFeature, language);
if (description) {
return description;
}
Expand Down Expand Up @@ -326,8 +327,8 @@ export class PublicPoiSidebarComponent extends BaseMapComponent implements OnDes
}

public navigateHere() {
const location = this.poiService.getLocation(this.fullFeature);
const title = this.poiService.getTitle(this.fullFeature, this.resources.getCurrentLanguageCodeSimplified());
const location = GeoJSONUtils.getLocation(this.fullFeature);
const title = GeoJSONUtils.getTitle(this.fullFeature, this.resources.getCurrentLanguageCodeSimplified());
this.navigateHereService.addNavigationSegment(location, title);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
* Maps last modified date
*/
lastModifiedDate: Date;
/**
* Points of interest last modified date
*/
poisLastModifiedDate: Date;
/**
* Shares last modified date
*/
Expand Down
1 change: 0 additions & 1 deletion IsraelHiking.Web/src/application/reducers/initial-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export const initialState =
offlineState: {
isOfflineAvailable: false,
lastModifiedDate: null,
poisLastModifiedDate: null,
shareUrlsLastModifiedDate: null,
uploadPoiQueue: [],
isPmtilesDownloaded: false
Expand Down
13 changes: 0 additions & 13 deletions IsraelHiking.Web/src/application/reducers/offline.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export class SetOfflineMapsLastModifiedDateAction {
constructor(public lastModifiedDate: Date) {}
}

export class SetOfflinePoisLastModifiedDateAction {
public static type = this.prototype.constructor.name;
constructor(public lastModifiedDate: Date) {}
}

export class SetShareUrlsLastModifiedDateAction {
public static type = this.prototype.constructor.name;
constructor(public lastModifiedDate: Date) {}
Expand Down Expand Up @@ -59,14 +54,6 @@ export class OfflineReducer {
}));
}

@Action(SetOfflinePoisLastModifiedDateAction)
public setOfflinePoisLastModifiedDate(ctx: StateContext<OfflineState>, action: SetOfflinePoisLastModifiedDateAction) {
ctx.setState(produce(ctx.getState(), lastState => {
lastState.poisLastModifiedDate = action.lastModifiedDate;
return lastState;
}));
}

@Action(SetShareUrlsLastModifiedDateAction)
public setShareUrlsLastModifiedDate(ctx: StateContext<OfflineState>, action: SetShareUrlsLastModifiedDateAction) {
ctx.setState(produce(ctx.getState(), lastState => {
Expand Down
58 changes: 7 additions & 51 deletions IsraelHiking.Web/src/application/services/database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ export class DatabaseService {
private static readonly STATE_DB_NAME = "State";
private static readonly STATE_TABLE_NAME = "state";
private static readonly STATE_DOC_ID = "state";
private static readonly POIS_DB_NAME = "PointsOfInterest";
private static readonly POIS_TABLE_NAME = "pois";
private static readonly POIS_UPLOAD_QUEUE_DB_NAME = "UploadQueue";
private static readonly POIS_UPLOAD_QUEUE_TABLE_NAME = "uploadQueue";
private static readonly POIS_ID_COLUMN = "properties.poiId";
private static readonly POIS_LOCATION_COLUMN = "[properties.poiGeolocation.lat+properties.poiGeolocation.lon]";
private static readonly IMAGES_DB_NAME = "Images";
private static readonly IMAGES_TABLE_NAME = "images";
private static readonly SHARE_URLS_DB_NAME = "ShareUrls";
Expand All @@ -36,7 +34,7 @@ export class DatabaseService {
private static readonly TRACES_TABLE_NAME = "traces";

private stateDatabase: Dexie;
private poisDatabase: Dexie;
private uploadQueueDatabase: Dexie;
private imagesDatabase: Dexie;
private shareUrlsDatabase: Dexie;
private tracesDatabase: Dexie;
Expand All @@ -54,11 +52,8 @@ export class DatabaseService {
this.stateDatabase.version(1).stores({
state: "id"
});
this.poisDatabase = new Dexie(DatabaseService.POIS_DB_NAME);
this.poisDatabase.version(1).stores({
pois: DatabaseService.POIS_ID_COLUMN + "," + DatabaseService.POIS_LOCATION_COLUMN,
});
this.poisDatabase.version(2).stores({
this.uploadQueueDatabase = new Dexie(DatabaseService.POIS_UPLOAD_QUEUE_DB_NAME);
this.uploadQueueDatabase.version(1).stores({
uploadQueue: DatabaseService.POIS_ID_COLUMN
});
this.imagesDatabase = new Dexie(DatabaseService.IMAGES_DB_NAME);
Expand Down Expand Up @@ -129,55 +124,16 @@ export class DatabaseService {
}
}

public storePois(pois: GeoJSON.Feature[]): Promise<any> {
return this.poisDatabase.table(DatabaseService.POIS_TABLE_NAME).bulkPut(pois);
}

public deletePois(poiIds: string[]): Promise<void> {
return this.poisDatabase.table(DatabaseService.POIS_TABLE_NAME).bulkDelete(poiIds);
}

public async getPoisForClustering(): Promise<GeoJSON.Feature<GeoJSON.Point>[]> {
this.loggingService.debug("[Database] Startting getting pois for clustering in chunks");
let features = [] as GeoJSON.Feature<GeoJSON.Point>[];
let index = 0;
const size = 2000;
let currentFeatures = [];
do {
currentFeatures = await this.poisDatabase.table(DatabaseService.POIS_TABLE_NAME).offset(index * size).limit(size).toArray();
features = features.concat(currentFeatures);
index++;
} while (currentFeatures.length !== 0);
this.loggingService.debug("[Database] Finished getting pois for clustering in chunks: " + features.length);
const pointFeatures = features.map((feature: GeoJSON.Feature) => {
const geoLocation = feature.properties.poiGeolocation;
const pointFeature = {
type: "Feature",
geometry: {
type: "Point",
coordinates: [parseFloat(geoLocation.lon), parseFloat(geoLocation.lat)]
},
properties: feature.properties
} as GeoJSON.Feature<GeoJSON.Point>;
return pointFeature;
});
return pointFeatures;
}

public getPoiById(id: string): Promise<GeoJSON.Feature> {
return this.poisDatabase.table(DatabaseService.POIS_TABLE_NAME).get(id);
}

public addPoiToUploadQueue(feature: GeoJSON.Feature): Promise<any> {
return this.poisDatabase.table(DatabaseService.POIS_UPLOAD_QUEUE_TABLE_NAME).put(feature);
return this.uploadQueueDatabase.table(DatabaseService.POIS_UPLOAD_QUEUE_TABLE_NAME).put(feature);
}

public getPoiFromUploadQueue(featureId: string): Promise<GeoJSON.Feature> {
return this.poisDatabase.table(DatabaseService.POIS_UPLOAD_QUEUE_TABLE_NAME).get(featureId);
return this.uploadQueueDatabase.table(DatabaseService.POIS_UPLOAD_QUEUE_TABLE_NAME).get(featureId);
}

public removePoiFromUploadQueue(featureId: string): Promise<void> {
return this.poisDatabase.table(DatabaseService.POIS_UPLOAD_QUEUE_TABLE_NAME).delete(featureId);
return this.uploadQueueDatabase.table(DatabaseService.POIS_UPLOAD_QUEUE_TABLE_NAME).delete(featureId);
}

public storeImages(images: ImageUrlAndData[]): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion IsraelHiking.Web/src/application/services/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export class FileService {
public async writeStyle(styleFileName: string, styleText: string) {
await this.fileSystemWrapper.writeFile(this.fileSystemWrapper.dataDirectory, styleFileName, styleText,
{ append: false, replace: true, truncate: 0 });
this.loggingService.info(`[Files] Write style finished succefully: ${styleFileName}`);
this.loggingService.info(`[Files] Write style finished successfully: ${styleFileName}`);
}

public async compressTextToBase64Zip(contents: {name: string; text: string}[]): Promise<string> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("FitBoundsService", () => {
const spy = jasmine.createSpy();
mapService.map.fitBounds = spy;
await service.fitBounds({ northEast: { lat: 1, lng: 1}, southWest: { lat: 2, lng: 2}});
console.log(spy.calls.all()[0].args[1]);
expect(spy.calls.all()[0].args[1].padding.left).toBe(400);
}));

Expand Down
Loading
Loading