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

For all coding issues - MODers and programmers, HTML and more.

Moderators: Jeff250, fliptw

Post Reply
User avatar
roid
DBB Master
DBB Master
Posts: 9996
Joined: Sun Dec 09, 2001 3:01 am
Location: Brisbane, Australia
Contact:

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

Post 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)
User avatar
fliptw
DBB DemiGod
DBB DemiGod
Posts: 6459
Joined: Sat Oct 24, 1998 2:01 am
Location: Calgary Alberta Canada

Post 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.
Richard Cranium
DBB Supporter
DBB Supporter
Posts: 1444
Joined: Tue Aug 07, 2001 2:01 am

Post 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.
User avatar
Iceman
DBB Habitual Type Killer
DBB Habitual Type Killer
Posts: 4929
Joined: Thu Apr 20, 2000 2:01 am
Location: Huntsville, AL. USA
Contact:

Post by Iceman »

I can do it, give me an hour ...
User avatar
Iceman
DBB Habitual Type Killer
DBB Habitual Type Killer
Posts: 4929
Joined: Thu Apr 20, 2000 2:01 am
Location: Huntsville, AL. USA
Contact:

Post 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.
User avatar
Iceman
DBB Habitual Type Killer
DBB Habitual Type Killer
Posts: 4929
Joined: Thu Apr 20, 2000 2:01 am
Location: Huntsville, AL. USA
Contact:

Post by Iceman »

Done, PM me if you have problems
User avatar
roid
DBB Master
DBB Master
Posts: 9996
Joined: Sun Dec 09, 2001 3:01 am
Location: Brisbane, Australia
Contact:

Post 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.
Post Reply