When you load a map into a
JViews Maps manager using the
map loader, this map is automatically displayed in the
coordinate system associated with the manager provided that the format
of the source data is georeferenced. The
IlvMapFeatureIterator interface has an
isGeoreferenced method that you can use to know whether a file is
georeferenced. Most of the cartographic files are georeferenced. This
is the case for files of the
DTED format. Some other cartographic formats, such as
Shapefile, are not georeferenced.
When loading data from a file that is not georeferenced,
and in the absence of any other indications, the map loader is unable
to reproject the source data within the target coordinate system (the
one associated with the manager).
Note
If you load several source files of the Shapefile format
whose projection is unknown in the same manager, objects are positioned
correctly. However, if you try to import data of another format in
the manager, the relative position of objects from different source
formats are inaccurate.
If you read a file whose format is not georeferenced,
but you know the coordinate system in which the data is expressed,
you can provide this information to the
IlvMapLoader using the
setDefaultCoordinateSystem method.
The following example shows how to import a Shapefile
whose projection is known to be geographic into a manager that is
in a Mercator projected coordinate system:
// Initialize the manager for the mercator projection.
IlvProjection p = new IlvMercatorProjection();
IlvProjectedCoordinateSystem pcs =
new IlvProjectedCoordinateSystem("mercator", p);
IlvCoordinateSystemProperty csProperty =
new IlvCoordinateSystemProperty(pcs);
manager.setNamedProperty(csProperty);
// Create a map loader.
IlvMapLoader mapLoader = new IlvMapLoader(manager);
// Load other data.
....
// Load a Shapefile expressed in geographic coordinate system. mapLoader.setDefaultCoordinateSystem(IlvGeographicCoordinateSystem.WGS84);
mapLoader.load("myShapeFile.shp");