APP REQUEST: Geodata Converter *CODED*

Started by Jingo, July 08, 2017, 07:17:45 PM

Previous topic - Next topic

Jingo






Script Name  Description  Requested byDate of RequestProgrammed by  Completed on 
Geodata Coordinate ConverterConversion of Lat/Long Geodata to other types of coordinates - UTM, British National Grid, etcDigPeter07.06.2017Jingo07.08.2017



   


Synopsis:

The Geodata Converter will convert the highlighted GPS coordinates for the selected image into several other standards including: Degrees, UTM and OSGB (for UK coordinates).  I also included the ability to copy results to the clipboard.  If anyone would like other modifications, please feel free to let me know.

I also hope this app will be used as a learning tool on how to interact with IMatch as well as update table data from script results.  I have added detailed comments into the HTML and script portion of the file to assist with code sharing for your own apps... feel free to borrow the code as needed... happy to explain anything that isn't clear as well. 

To install, just unzip the file contents to the C:\ProgramData\photools.com\imatch6\webroot\user folder - the app should automatically appear in the App panel.

Enjoy! - Andy.

Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

DigPeter

#2
Thanks Andy for this fast response.  I will convert to IM2017 in due course, but am not ready yet to do so.  I realise that there are several converters available and I use a couple, but have to manually copy and paste the lat/long coords to get the result.  To do it straight from IM will be a great help.


Peter

sinus

Super, Andy, looks really good!  :)
Thanks for sharing!
Best wishes from Switzerland! :-)
Markus

Jingo

Quote from: DigPeter on July 08, 2017, 11:09:25 PM
Thanks Andy for this fast response.  I will convert to IM2017 in due course, but am not ready yet to do so.  I realise that there are several converters available and I use a couple, but have to manually copy and paste the lat/long coords to get the result.  To do it straight from IM will be a great help.


Peter

You bet Peter... as mentioned, this was a great learning moment for me so I appreciate the opportunity to code an app that has "real life" usage.  It works wonderfully from within Imatch on the selected image so hopefully when you make the jump - it will be there waiting for you!  I was thinking of also adding in some free text fields so anyone can just type in values to generate results - totally independent of an image selection (or GPS coords).

Enjoy!

Jingo

Quote from: sinus on July 09, 2017, 12:04:27 AM
Super, Andy, looks really good!  :)
Thanks for sharing!

Thanks Markus... it was great fun to create!!

Carlo Didier

Good work Andy!
I was looking for such an algorithm for some time.
I'll try to convert it into an old iMatch Basic code to include in my event scripts there.
I hope I'll understand enough of your javascript to extract the algorithm.

Jingo

Quote from: Carlo Didier on July 09, 2017, 08:25:44 PM
Good work Andy!
I was looking for such an algorithm for some time.
I'll try to convert it into an old iMatch Basic code to include in my event scripts there.
I hope I'll understand enough of your javascript to extract the algorithm.

Thx Carlo... it was a great learning experience for me and a great way to jumpstart my intro to IMatch apps in Javascript.  If you have any questions about the code, please let me know.  Enjoy! - Andy.

DigPeter

@Andy
This app works excellently.  Could you please consider a refinement?  It would be useful and helpful if the dialog could provide the option of writing a result into the metadata of a selected file.  I do not know about the the technicalities and there might be some reason that this is not possible or undesirable, but I visualise that there would be a button for each of the UTM and the OSGB results to write the data into appropriate metadata field or fields, which could then be displayed in the metadata panel.  This can of course be done now indirectly by copying the data into such a field displayed in the metadata panel, but it would be more convenient and quicker to do this from your dialog.

Jingo

Hi Peter - this wouldn't be difficult at all.. but what XMP fields should these value be written to?  Would we just create new IMatch:XMP records for these values?

DigPeter

Quote from: Jingo on August 13, 2017, 09:19:29 PM
Hi Peter - this wouldn't be difficult at all.. but what XMP fields should these value be written to?  Would we just create new IMatch:XMP records for these values?
Sorry - as I said, I do not know the technical stuff.  Perhaps Mario could advise.

Jingo

Quote from: DigPeter on August 13, 2017, 09:26:24 PM
Quote from: Jingo on August 13, 2017, 09:19:29 PM
Hi Peter - this wouldn't be difficult at all.. but what XMP fields should these value be written to?  Would we just create new IMatch:XMP records for these values?
Sorry - as I said, I do not know the technical stuff.  Perhaps Mario could advise.

Yeah... I'm not sure there are "standard" XMP fields for this data... certainly custom ones could be created but I'm not sure what these should be as most folks interested in this data might be putting it in very specific fields for their specific use.  I only coded the app based upon the original vbasic version which simply made it available to the clipboard - perhaps for pasting into a custom XMP field.. or perhaps for appending to the description.

DigPeter

Quote from: Jingo on August 13, 2017, 11:03:42 PM
Yeah... I'm not sure there are "standard" XMP fields for this data... certainly custom ones could be created but I'm not sure what these should be as most folks interested in this data might be putting it in very specific fields for their specific use.  I only coded the app based upon the original vbasic version which simply made it available to the clipboard - perhaps for pasting into a custom XMP field.. or perhaps for appending to the description.
Various threads in the past have mentioned what I understand to be general purpose XMP fields.  I imagine that Mario can advise.

Mario

IMatch does not allow to create custom namespaces in XMP. Just not worth the trouble.

I did not follow this thread but usually the XMP description, title or headline is free text. Or any of the other (IPTC) XMP fields.
If you use your files only in private, you can do whatever you want, just don't break anything.

See: https://iptc.org/standards/photo-metadata/guidelines-support/ for more info.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

Interesting... given the fact that there are really no good places to put this data with a button (each person might want to put it someplace different) - I'm leaning towards just leaving the copy to clipboard functionality in place.. if anyone can provide other ideas/options - happy to include buttons for those specific operations.  Thx!

DigPeter

Quote from: Jingo on August 14, 2017, 03:59:05 PM
Interesting... given the fact that there are really no good places to put this data with a button (each person might want to put it someplace different) - I'm leaning towards just leaving the copy to clipboard functionality in place.. if anyone can provide other ideas/options - happy to include buttons for those specific operations.  Thx!
Oh well - thanks for thinking about it, Andy.   I can do it by Copy & Paste to an appropriate field.  Could you device some code which will round the Eastings & Northings of the OSGB data up or down to the nearest 4 figures - e.g. SU 22191 01437 becomes SU 2219 0144.  GPS devices are not a accurate enough for the last figure to be meaningful.  4 figures gives +/-10m accuracy, which for practical purposes is good enough.  No need to publish a new html file.  If you tell me where I will insert it myself.  Thanks.

DigPeter

Quote from: Mario on August 14, 2017, 09:12:14 AM
IMatch does not allow to create custom namespaces in XMP. Just not worth the trouble.

I did not follow this thread but usually the XMP description, title or headline is free text. Or any of the other (IPTC) XMP fields.
If you use your files only in private, you can do whatever you want, just don't break anything.

See: https://iptc.org/standards/photo-metadata/guidelines-support/ for more info.
I have added the tag XMP::Plus\Custom1 to the metadata panel and this accepts copy & paste data.  Is it alright to continue using that tag?  Is it possible to change the title of the tag displayed in the panel - to say "OSGB"?

Jingo

Quote from: DigPeter on August 14, 2017, 05:09:07 PM
Quote from: Jingo on August 14, 2017, 03:59:05 PM
Interesting... given the fact that there are really no good places to put this data with a button (each person might want to put it someplace different) - I'm leaning towards just leaving the copy to clipboard functionality in place.. if anyone can provide other ideas/options - happy to include buttons for those specific operations.  Thx!
Oh well - thanks for thinking about it, Andy.   I can do it by Copy & Paste to an appropriate field.  Could you device some code which will round the Eastings & Northings of the OSGB data up or down to the nearest 4 figures - e.g. SU 22191 01437 becomes SU 2219 0144.  GPS devices are not a accurate enough for the last figure to be meaningful.  4 figures gives +/-10m accuracy, which for practical purposes is good enough.  No need to publish a new html file.  If you tell me where I will insert it myself.  Thanks.

Hi Peter - its easy to target a field... I'll work on something where you can id an xmp field to paste the data to.

To get 4 digits instead of 5 - just change this line to (4) instead of (5)....

         // ---> get a grid reference with 5 digits of precision
                        var gridref = osgb.getGridRef(5);

Enjoy! - Andy

DigPeter


Mario

Quote from: DigPeter on August 14, 2017, 05:18:19 PM
Is it possible to change the title of the tag displayed in the panel - to say "OSGB"?
You configure the name of the tag in the Metadata Panel Layout. Just enter another Caption for the tag. If you leave the caption empty, IMatch uses the official tag name.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

It's been awhile - but Peter requested a modification to the app that allows the UTM to directly update the selected files instead of just copying values to a clipboard.. so, V2 has been made available.

Just download the new zip and overwrite the existing file... a new button should appear to perform the copy.

Enjoy!

owCnL3MXMh.png

Jingo

I have made some modifications for Peter to include a new button that converts each selected images' GPS coords to OSGB and writes that value back to each selected image (instead of using the highlighted value).

So - clicking the YELLOW button will use the highlighted image as the source and write this converted value to ALL selected images (original functionality).  Clicking the RED button will convert each selected image and write that converted value to the selected image file XMP field.

I tested this on a few sample images and it seemed to work fine... Peter - let me know if this version works for you too!  Just download the zip file and extract the folder to overwrite the files.. this is version 3 and the json file has been updated as such.

Enjoy!

IMatch2021x64_GmPRnUsxgE.png

sinus

Thank, Jingo for your hard work and sharing!  :)

Though I cannot use this app, because I even do not know, what OSGB is  ;D :-[
Best wishes from Switzerland! :-)
Markus

Mario

Quote from: sinus on May 22, 2023, 04:30:44 PMThank, Jingo for your hard work and sharing! :)

Though I cannot use this app, because I even do not know, what OSGB is  ;D :-[

It's a very British thing and interesting: https://en.wikipedia.org/wiki/Ordnance_Survey_National_Grid

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

DigPeter

Brill - red button works like magic.   Great job and very many thanks, Andy

Jingo

Quote from: DigPeter on May 22, 2023, 09:04:14 PMBrill - red button works like magic.  Great job and very many thanks, Andy

Fantastic!  Glad to help and enjoy!  The APP Store is always open for requests... keep 'em coming folks!   ;D

DigPeter

Quote from: sinus on May 22, 2023, 04:30:44 PMThank, Jingo for your hard work and sharing! :)
Though I cannot use this app, because I even do not know, what OSGB is  ;D :-[
This script was requested specifically with British National Grid and British maps in mind.  Jingo has added value by including UTM grid which is a universal alternative to Geodetic grid (lat/long) and used with many maps worldwide (@Sinus - I think, including Switzerland).