Activity › Forums › Adobe After Effects Expressions › Fake Geo coordinates
-
Fake Geo coordinates
Posted by Rob Chan on October 21, 2014 at 6:23 pmHi
I need some expressions help please.
The best way to describe what I require is a set of Geo coordinates like you’d find on a GPS.
I want to move a layer around and have text display ˚ ‘ ” after the numbers.
I’ve figured out how to create some numbers by using some of the position values but I have no idea how to add in the symbols.Can anyone offer any kindly help?
Thanks
Robp1 = thisComp.layer("OBJECT").transform.position[0];[(Math.round(p1))]
Rob Chan replied 11 years, 11 months ago 2 Members · 6 Replies -
6 Replies
-
Kevin Camp
October 21, 2014 at 11:23 pmthis will make the x and y values seem like longitude and latitude values:
p = thisComp.layer("OBJECT").transform.position[0];s = 10;
xOffset = 100;
yOffset = 50;x = xOffset + s * p[0] / 360;
y = yOffset + s* p[1] / 180;lonDeg = Math.floor(x) % 360;
lonMin = Math.floor(60 * (x - lonDeg));
lonSec = Math.floor(3600 * (x - lonDeg - lonMin/60));
longitude = lonDeg + "° " + lonMin + String.fromCharCode(34) + " " + lonSec + String.fromCharCode(39)latDeg = Math.floor(y) % 180;
latMin = Math.floor(60 * (y - latDeg));
latSec = Math.floor(3600 * (y - latDeg - latMin/60));
latitude = latDeg + "° " + latMin + String.fromCharCode(34) + " " + latSec + String.fromCharCode(39)longitude + ", " + latitude
s is like a scale factor, it controls the amount change per pixel. xOffset and yOffset allow you have the longitude and latitude values start at larger values.
it’s not really very realistic, but the format will seem about right. with better math, it could be fairly realistic.
Kevin Camp
Art Director
KCPQ, KZJO & KRCW -
Rob Chan
October 22, 2014 at 7:19 amHi Kevin
Thank you for your prompt response!
Please forgive my lack of knowledge with Expressions, but when I paste your code in I get the following message…
After Effects warning: property or method named ‘0’ in Class “Number’ is missing or does not exist. It may have been renamed, moved, deleted, or the name may have been mistyped. A property expression referencing it was disabled.
‘Source Text’ (line 7) of layer 1 (”) in comp ‘Coordinates’
Any ideas how to resolve this, I’ve tried looking at the code at line 7 but am stumped.
Thanks
Rob -
Kevin Camp
October 22, 2014 at 4:15 pmsorry the main problem was the first line was only looking at the x component of ‘object’, i didn’t catch that in your expression (i assume you want both x and y, if not we can change this).
i was also missing 2 semicolons at the end of 2 lines, but that shouldn’t have caused the error.
this should work:
p = thisComp.layer("OBJECT").transform.position;s = 10;
xOffset = 100;
yOffset = 50;x = xOffset + s * p[0] / 360;
y = yOffset + s* p[1] / 180;lonDeg = Math.floor(x) % 360;
lonMin = Math.floor(60 * (x - lonDeg));
lonSec = Math.floor(3600 * (x - lonDeg - lonMin/60));
longitude = lonDeg + "° " + lonMin + String.fromCharCode(34) + " " + lonSec + String.fromCharCode(39);latDeg = Math.floor(y) % 180;
latMin = Math.floor(60 * (y - latDeg));
latSec = Math.floor(3600 * (y - latDeg - latMin/60)); latitude = latDeg + "° " + latMin + String.fromCharCode(34) + " " + latSec + String.fromCharCode(39);longitude + ", " + latitude;
Kevin Camp
Art Director
KCPQ, KZJO & KRCW -
Rob Chan
October 22, 2014 at 4:23 pmHi Kevin
…Thanks for responding, but I still can’t get this to work – similar message as last time
After Effects warning: property or method named ‘transform’ in Class “Property’ is missing or does not exist. It may have been renamed, moved, deleted, or the name may have been mistyped. A property expression referencing it was disabled.
‘Source Text’ (line 7) of layer 1 (”) in comp ‘Coordinates’
Any clues?
Thanks once again!
Rob -
Kevin Camp
October 22, 2014 at 8:32 pmHi Rob,
I don’t have an error here… i am using an old version of ae, but i don’t think there’s any syntax that has changed that would be effecting this expression.
do you have a layer named “OBJECT” in the comp? your original expression was pointed at a layer named “OBJECT” so i used the same layer name. however if that was the issue, normally the error would say say something to the effect of that layer could not be found, but that’s the first thing that comes to mind…
do you have the latest updates to your version of after effects, and/or have you rebooted your computer lately?
Kevin Camp
Art Director
KCPQ, KZJO & KRCW -
Rob Chan
October 22, 2014 at 9:14 pmHi Kevin
Thank you, a restart did the trick!
Amazing help Kevin, Much appreciated!Rob
Reply to this Discussion! Login or Sign Up