Hi, I'm trying to create an SQL in Sqlite3 which returns the X & Y coords for a point, given origin coordinates in degrees, with distance and bearing to the new location.
My install of Spatialite (Mint Linux) does not support the Project() function, and it seems easier to write the SQL required, based on the code at this site, than sort this out: https://www.movable-type.co.uk/scripts/latlong.html I implemented the SQL for calculating the lat which works fine. I then wrestled with the SQL for longitude, which kept giving wrong answers. I tried it in a spreadsheet (Libre Office) which works fine. I then tried the same SQL in Postgres - and got the correct answer. Can anyone suggest a way to get this working in Sqlite3? For a point at 42S 175E moved east 200m: sqlite> select degrees( radians(175) + atan2( sin(radians(90)) * sin(0.2/6378.14)*cos(radians(-42)), cos(0.2/6378.14) - sin(radians(-42))*sin(radians(-42)))); 264.997582396241 postgres=# select degrees( radians(175) + atan2( sin(radians(90)) * sin(0.2/6378.14)*cos(radians(-42)), cos(0.2/6378.14) - sin(radians(-42))*sin(radians(-42)))); degrees ------------------ 175.002417603759 Note that I have a workaround which should be OK for the small distances I'm using: Lat: select -42 + (200*cos(radians(0))/110540); Lon: select 175+(200*sin(radians(0))/(111320/cos(radians(-42)))); (change the "0" to the angle required and the "200" to the distance in m required, -42=start lat, 175 = start lon) Thanks Brent Wood _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users