[OSM2World] where is the origin?
Julien JPK
julienjpk at email.com
Tue Mar 27 11:41:27 UTC 2018
On 27/03/18 12:27, Virginie Galtier wrote:
> For each OBJ file, I would need the GPS position of the point considered
> as the origin (this way once the first OBJ file is rendered to V-REP, I
> can compute the x,y offset where to render the next OBJ file). I've
> tried comparing the OSM and OBJ files, looking at OSM2World source code
> to figure out what could that be but I'm not skilled enough.
Hello,
If I'm not mistaken, the "origin" is determined from the OSM file, using
the centre of its bounding box, which is then projected just like the
rest of the extract through Mercator projection.
If you have a look at the OriginMapProjection class, you'll see the
first step in the setOrigin method:
-
https://github.com/tordanik/OSM2World/blob/36f3a95a3e709faee9c796d9536615557915f45d/src/org/osm2world/core/map_data/creation/OriginMapProjection.java
Once the geodetic coordinates of this point have been determined, you
may ask yourself how they translate into (x,y) coordinates in the OBJ
file. The answer to that in the ConversionFacade class:
-
https://github.com/tordanik/OSM2World/blob/36f3a95a3e709faee9c796d9536615557915f45d/src/org/osm2world/core/ConversionFacade.java#L159
You can see that the projection is performed using the
MetricMapProjection class. You can find it here:
-
https://github.com/tordanik/OSM2World/blob/36f3a95a3e709faee9c796d9536615557915f45d/src/org/osm2world/core/map_data/creation/MetricMapProjection.java
The setOrigin method will tell you how the origin's geodetic coordinates
are converted:
-
https://github.com/tordanik/OSM2World/blob/36f3a95a3e709faee9c796d9536615557915f45d/src/org/osm2world/core/map_data/creation/MetricMapProjection.java#L61
All you have to do then is apply that calculation to the origin we
mentioned earlier. You can find the MercatorProjection class here...
-
https://github.com/tordanik/OSM2World/blob/36f3a95a3e709faee9c796d9536615557915f45d/src/org/osm2world/core/map_data/creation/MercatorProjection.java
... for the lonToX, latToY and earthCircumference static methods.
Good luck!
--
Julien JPK (0xC3075A58)
julienjpk at email.com
More information about the OSM2World
mailing list