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

Panoramax: Adopt "copy id" feature from mapillary #10856

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

MohamedAli00949
Copy link

Hi there,

This is my code to add the copy id button at the Panoramax image

Changes

  • "Copy ID" button component.

Issue

Closes #10611

@tordans
Copy link
Collaborator

tordans commented Mar 10, 2025

From reading the code I don't see how this PR could resolve the requirements described in the issue, specifically #10611 (comment) and #10611 (comment)

@MohamedAli00949
Copy link
Author

MohamedAli00949 commented Mar 10, 2025

As I understood the issue, I found the requirements are to add the copy id button to the photo viewer, such as below, and research imagery services such as Panoramax photo viewer. I have replied with the research results.
Screenshot 2025-03-10 111753

So, what is wrong with my implementation? and How to improve it.

Thanks in advanced

@MohamedAli00949
Copy link
Author

@tordans, Do you mean that I haven't used the panoramax=* field and want to use it at the copy button instead of passing it to the function or another thing?

@tyrasd tyrasd added the streetlevel An issue with streetlevel photos label Mar 10, 2025
@MohamedAli00949
Copy link
Author

@tordans, after reading the related modules to this feature, I have found another solution to solving this problem using hash (search hash params class, or using context). Is this suitable?

Copy link
Member

@tyrasd tyrasd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should work like the corresponding button on mapillary photos:

image

@MohamedAli00949
Copy link
Author

Ok, But I will use the copy icon instead of the plus

@MohamedAli00949 MohamedAli00949 force-pushed the enh/add-panoramax-copy-id branch from ddfda67 to 366dc0a Compare March 12, 2025 05:22
@MohamedAli00949
Copy link
Author

Hi @tyrasd,
I have changed the component, but the street-side photo viewer appears as the following.
image

I suggest the following style:
image
If my suggestion is good, I will commit these changes.

@tyrasd
Copy link
Member

tyrasd commented Mar 12, 2025

please use the same icon as used in the mapillary viewer. otherwise this would be very confusing.

@tordans
Copy link
Collaborator

tordans commented Mar 12, 2025

@tyrasd I think the main thing we need to agree on first is, what solution does resolve the linked issue. I outlined my proposal in the links above. The core idea of that is, to use what we have for Mapillary and abstract it to reuse of other image providers. This is not what is being proposed here as far as I understand the code but instead a copy button that would require to manually add the key and paste the value. As a result we would have two features doing something very similar – one better then the other.

My recommendation would be to clarify what we are looking for so this PR might be adjusted … or otherwise closed as it is not what we should merge IMO.

@tyrasd
Copy link
Member

tyrasd commented Mar 12, 2025

The core idea of that is, to use what we have for Mapillary and abstract it to reuse of other image providers.

I agree, that's basically what I meant with it should work like the corresponding button on mapillary photos above. 🤷

A copy-to-clipboard button is definitely not going to cut it here.

@gedankenstuecke
Copy link

I've rephrased the original issue I had opened to make it clearer that the "agreed" solution is copying the mapillary-functionality

@MohamedAli00949 MohamedAli00949 force-pushed the enh/add-panoramax-copy-id branch from 366dc0a to 3e705dd Compare March 13, 2025 02:49
@MohamedAli00949
Copy link
Author

I am so sorry, for the misunderstanding.
Latterly, I added the functionality to set the photo button which was implemented before at mapillary.
But, there's to other issues,

The first is the plus icon, which provides a bad experience and I suggest replacing it with the following icon (such as @tordans has been suggested before at mapillary implementation).
image

The second is the position of the zoom icons in the panormax photo as in the following image and I suggest moving them down a bit.
image

If one of my suggestions or both isn't right tell me to change them.

Copy link
Collaborator

@tordans tordans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

.every(value => value === activeImage?.id)) {
const entitiesWithTag = entities.map(entity => entity.tags[tagName] ? entity.tags[tagName] : undefined).filter(e => e);
const isPhotoUsed = entitiesWithTag
.some(value => value === activeImage?.id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part checks if the "looked at" image id is already present in the tags value, right?
We should make this something like value.includes(activeImage?.id) to account for the edge case that multiple image ids are used separated by ;, eg. "<id1>;<id2>". (We talked about that practice while reviewing openstreetmap/id-tagging-schema#1344)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting to see the change from every to some. That was a bug in the previous implementation, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting to see the change from every to some. That was a bug in the previous implementation, right?

This is right, I have found this bug and I have rewritten this line to refactor the function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part checks if the "looked at" image id is already present in the tags value, right? We should make this something like value.includes(activeImage?.id) to account for the edge case that multiple image ids are used separated by ;, eg. "<id1>;<id2>". (We talked about that practice while reviewing openstreetmap/id-tagging-schema#1344)

Okay, this is more effective, I will apply it.

Thanks, a lot.

if (services.mapillary.isViewerOpen()) {
if (context.mode().id !== 'select' || !(layerStatus('mapillary') && getServiceId() === 'mapillary')) {
const service = getServiceId();
const isActiveService = ['mapillary', 'panoramax'].includes(service) && services[service].isViewerOpen();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets extract this array into something like a const PHOTO_SERVICES_WITH_TAG_BUTTON = [] to give it a bit more visibility that this is the place where we configure the services. Please check the code conventions on such const (naming in placement in file); I don't know how that is done elsewhere in the codebase.

We are also making the assumption here that the service name and tag key will be the same. That is true for those two but might be different for others. We could account for this now… but it feels like premature optimization so I would do it in a refactoring later when the need comes up.

if (context.mode().id !== 'select' || !(layerStatus('mapillary') && getServiceId() === 'mapillary')) {
const service = getServiceId();
const isActiveService = ['mapillary', 'panoramax'].includes(service) && services[service].isViewerOpen();
const mapillaryOrPanoramax = (layerStatus(service) && ['mapillary', 'panoramax'].includes(service));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Lets use a more generic name for the const
  • Lets reuse the same array defined once above

Can you double check the conditions, I think that isActiveService already accounts for the second condition in this check, right?

const mapillaryOrPanoramax = (layerStatus(service) && ['mapillary', 'panoramax'].includes(service));

if (isActiveService) {
if (context.mode().id !== 'select' || !(mapillaryOrPanoramax)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (context.mode().id !== 'select' || !(mapillaryOrPanoramax)) {
if (context.mode().id !== 'select' || !mapillaryOrPanoramax) {

function setMapillaryPhotoId() {
const service = services.mapillary;
const image = service.getActiveImage();
function setMapillaryOrPanoramaxPhotoId() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like above, lets look for a name that is more generic.

What would be a good name to describe the general feature? "addPhotoServiceTag", "applyTagOfPhotoService",…

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think addPhotoServiceTag is more expressional to its implementation.


const graph = context.graph();
const entities = context.selectedIDs()
.map(id => graph.entity(id));

if (entities.map(entity => entity.tags.mapillary)
.every(value => value === activeImage?.id)) {
const entitiesWithTag = entities.map(entity => entity.tags[tagName] ? entity.tags[tagName] : undefined).filter(e => e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be the same but shorter, right?

Suggested change
const entitiesWithTag = entities.map(entity => entity.tags[tagName] ? entity.tags[tagName] : undefined).filter(e => e);
const entitiesWithTag = entities.map(entity => entity.tags[tagName]).filter(Boolean);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks

@tordans
Copy link
Collaborator

tordans commented Mar 13, 2025

Given the research you did in #10611 (comment) I only see on other service that has a dedicated wiki page about a dedicated tag which is https://wiki.openstreetmap.org/wiki/Key:kartaview

I don't think Kartaview is especially active / used in OSM and the tag has low usage with ~600 https://taginfo.openstreetmap.org/keys/kartaview but we could look into adding this as well. The Kartaview UI might require extra work though, in which case I would rather skip it for later due to the low usage.

@tordans
Copy link
Collaborator

tordans commented Mar 13, 2025

Re #10856 (comment)

Choosing the icon

Personally, I agree that the plus is a no go given the +/- for Zooming and that from the list we #10046 (comment) researched last time the one you chose is the best choice. Martin might see it differently but I suggest to go with that for now.

Position of button

@MohamedAli00949
Copy link
Author

Given the research you did in #10611 (comment) I only see on other service that has a dedicated wiki page about a dedicated tag which is https://wiki.openstreetmap.org/wiki/Key:kartaview

I don't think Kartaview is especially active / used in OSM and the tag has low usage with ~600 https://taginfo.openstreetmap.org/keys/kartaview but we could look into adding this as well. The Kartaview UI might require extra work though, in which case I would rather skip it for later due to the low usage.

Yeah, this is right.
But I can't see this field used in schema fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
streetlevel An issue with streetlevel photos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panoramax: Adopt "copy id" feature from mapillary
4 participants