Page 1 of 1

can someone please write a very simple script/program for me

Posted: Thu Aug 25, 2005 10:50 pm
by roid
i need a script or basically just some very simple program that can go through a single text file and perform calculations on what it reads.
(if you'd like some background info - i need to slightly move every single one of my googleearth placemarks by the same amount, they are stored in a KML file which is a text format which reads similar to HTML. but you don't really need to know that.)

whenever it comes to a:
<longitude>153.0383065339457</longitude> <- (the number can be anything)
it needs to add 0.000236 to it.
something like a X = X + 0.000236 calculation.

likewise whenever it come to a:
<latitude>-27.3234919378792</latitude>
it needs to subtract 0.000099 from it, like Y = Y - 0.000099


also these same latitude and longitude coordinates are stored in a fashion of: <coordinates>153.0383780839505,-27.32346712044058,0</coordinates>

or multiple coordinates can be stored eg:
<coordinates>153.0381411994351,-27.32336782241054,0 153.0380886432859,-27.32356806599593,0 153.0377780926332,-27.32352752614733,0 153.0374658800643,-27.32529301530822,0 153.0374017293408,-27.32602554183629,0 153.0370678824056,-27.327709605444,0 153.0419233643279,-27.32855869540169,0 153.0413454586722,-27.33142339015328,0</coordinates>

it's basicly <coordinates> X,Y,0 X,Y,0 X,Y,0 X,Y,0</coordinates> with each set seperated by a space.
as with the first example it's the same:
all X figures needs have have 0.000236 added to it.
all Y figures needs to have 0.000099 subtracted from it.
the 0, space, and commas are left untouched.


i'm not knowledgeable enough atm in programming to be able to write a program/script that can do this. but it seems very simple to do, so can someone please help by writing something i can run that will do this?

perhaps it can be done with a script run in another program that i already have - i have the MS Office suite if that can help, and i likely have java installed. i don't know, i'm sure you'll know a good idea! :D

even if you don't write something, some advice would be helpful.
(i have done various forms of programming over the years, but i havn't done any for a while and as a result i am unfamilure with the syntax for the langauges i have and don't know howto work the compilers)

Posted: Thu Aug 25, 2005 11:28 pm
by fliptw
XML parsers aren't simple things. which is what the KML files are it seems.

Yes, we need to know what the file is before we can start working on it.

Posted: Thu Aug 25, 2005 11:58 pm
by Richard Cranium
Can't MS Excel read XML files? You might be able to use something like that and write a macro to do it for you... It might take several macros (or several passes) to get it all done...

Just an idea.

Posted: Fri Sep 02, 2005 8:50 am
by Iceman
I can do it, give me an hour ...

Posted: Fri Sep 02, 2005 9:37 am
by Iceman
App is here : http://www.knology.net/~pleopard/KMLShifter.exe

This works for all cases but the multiple coordinates. I will finish that later if this tool is useful for you.

Posted: Fri Sep 02, 2005 12:05 pm
by Iceman
Done, PM me if you have problems

Posted: Sun Sep 04, 2005 2:26 am
by roid
thanks a bunch iceman. another guy made a program to do the multiple coordinates, so with that and yours i'm set :D

thx again.