Closed Rubix982 closed 3 years ago
@cbeddow The images be should be returned as URLS, right?
@Rubix982 no, we should return the full GeoJSON feature of the image. So we at first get a geojson feature collection from the tiles, and need to analyze the camera_angle of each feature to see if the image points towards the input lon,lat. The one that is the best candidate should then be returned as a feature. The user then can use the whole feature, for example plot it on a map or just print the image key, as they need.
@Rubix982 this javascript code shows how looking at can be calculated, maybe is partially useful:
function isLookingAt(imageFeature: any, lookatFeature: any): boolean {
if (imageFeature.properties.pano) {
return true;
}
// TODO ca < 0 or ca === -1?
if (imageFeature.properties.ca < 0) {
return false;
}
const bearing: number = Math.abs(turf.bearing(imageFeature, lookatFeature) - imageFeature.properties.ca) % 360;
return 310 < bearing || bearing < 50;
}
function filterHitsByLookAt<T extends {_source: MapImage}>(hits: T[], lookat: {lng: number, lat: number}): T[] {
const lookatFeature: any = turf.point([lookat.lng, lookat.lat]);
return hits.filter(
(image): boolean => {
const coords = [image._source.l.lon, image._source.l.lat];
const imageFeature = turf.point(coords, {'ca': image._source.ca});
return isLookingAt(imageFeature, lookatFeature);
},
);
}
Noted. Thanks for the code snippet!
Self assigning.
Is your feature request related to a problem? Please describe. This issue deals with the 1st requirement from the PRD for specifying two 2 sets of longitude, and latitude, where the 2nd set is the "looking at" location from 1st set's perspective.
Describe the solution you'd like The base requirements are,
The options mentioned above are,
Describe alternatives you've considered NA
Additional context Maybe eliminate arguments being 2 sets of longitude, latitude, only have 1 longitude, latitude for looking at.
It may be useful to have the function exclude images that are too close to the looking at longitude, latitude, as if within 3 meters, as the returned photo may be too close to be useful. 10+ meters may be best