Vector data sources

The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir> /jviews-maps810/samples/mapbuilder/index.html

ESRI shapefile

When you create a Shapefile format data source the shapefiles can be loaded with or without the tiling mechanism. When using tiling, the data is loaded in a background thread.
The complete source code for an ESRI shapefile demonstration can be found at <installdir> /jviews-maps810/shape/mapbuilder/index.html

Loading a shapefile using tiling

To load a shapefile using tiling, use the following code:
IlvTiledShapeDataSource tiledSource = new 
IlvTiledShapeDataSource(shpFileName,true);
If the shapefile does not have a tiling index file, you can create the index file as follows:
IlvShapeFileTiler tiler = new IlvShapeFileTiler(shpFileName, shxFileName, 
indexFileName, tileWidth, tileHeight);
while(tiler.getNextFeature() != null) {
  tiler.addInfo();
}
tiler.close();
The resulting index file, which is used in the reader, can be set with a call to:
tiledSource.setIdxFilename(idxFileName);

Loading a shapefile without using tiling

To load a shapefile without using tiling, use the following code:
IlvShapeDataSource shpDataSource = new IlvShapeDataSource(shpFileName, true); 

MID/MIF

To create a MID/MIF file data source, use the following code:
IlvMapDataSource source = new IlvMIDMIFDataSource(fileName);
source.setManager(getView().getManager());     

TIGER/Line

To create a TIGER/Line data source, use the following code:
IlvTigerDataSource source = new IlvTigerDataSource(fileName);
source.setManager(getView().getManager());
TIGER/Line® data contains many different features. You can select the features to import into your map by choosing the CFCC codes of the features you want:
source.setCFCCCodeList(CFCCCodes);

DXF (AutoCAD)

The DXF format (Drawing Interchange Format) is the interchange format for AutoCAD. This format supports vector graphics (polygons, arcs, lines, points...) and layers.
The specifications of the various releases of the DXF format can be found at the following URL: http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=5129239.
For details of the limitations with a DXF data source, refer to Drawing Exchange Format (DXF) in the section on managers in The Essential JViews Framework.
To create a DXF data source, use the following code:
IlvDXFDataSource source = new IlvDXFDataSource("C:/maps/DXF/maps.dxf");
source.setManager(getView().getManager());
You must then set up the transformation you want to use to read DXF.
If you want to transform the DXF extent into the latitude/longitude range provided, call:
source.setDestinationBounds(lonMinRad,latMinRad,lonMaxRad,latMaxRad);
If you want to use a more complex transformation (such as reprojection), call:
IlvMathTransform mathTransform =…/create mathematical transformation
   source.setInternalTransformation(mathTransform);
An example of how to create a complex transformation is given in the Map Builder demonstration, through use of the DXFControlModel class.

KML or KMZ

KML/ KMZ is an XML-based numerical map format containing both vectorial and raster information. KML is published by Google™ , for use in their Google Earth© Product.
You can find more information at http://earth.google.com/kml/kml_intro.html.
JViews Maps supports import of the KML elements shown in KML element support:
KML element support
Element
Support
Placemarks
Geometric Shapes, Location.
Geometry
Points, Lines, Polygons.
Image Overlays
Ground Overlays.
Styles
No Support.
Grouping Mechanisms
Documents, Folders, Geometry Collections.
Network Links
Locations.
KML files can refer to other files, either locally or through a network link URL. KMZ is a compressed file containing a single doc.xml entry and a set of auxiliary files, such as images or icons.
To create a KML data source, use the following code:
IlvKMLDataSource source = new IlvKMLDataSource("C:/maps/KML/places.kmz");
source.setManager(getView().getManager());

SVG

SVG (Scalable Vector Graphic) is a language for describing two-dimensional graphics and graphical applications in XML. The specifications of the SVG format can be found at http://www.w3.org/Graphics/SVG.
The JViews Maps SVG reader is based on features in Rogue Wave® JViews Framework. These features are described in the section on Scalable Vector Graphics in The Advanced JViews Framework.
The JViews Maps SVG reader ignores the following SVG elements:
  • Images defined through the image element.
  • Text defined through the text-path element.
All the other elements, including text elements, are transformed into IlvMapGeneralPath instances.
The graphic styles in the resulting map are rendered to look as close as possible to the original version. However, the styles created are limited to the data available for styling such an object.
To create an SVG data source, use the following code:
IlvSVGDataSource source = new IlvSVGDataSource("C:/maps/SVG/maps.svg");
source.setManager(getView().getManager());
You then need to set up the transformation you want to use to read SVG. To transform the SVG extent into the latitude/longitude range provided, call:
source.setDestinationBounds(lonMinRad,latMinRad,lonMaxRad,latMaxRad);
To use a more complex transformations such as reprojection, call:
IlvMathTransform mathTransform = //create mathematical transformation
source.setInternalTransformation(mathTransform);
An example of how to create a complex transformation using of the ControlModel example class can be found at <installdir> /jviews-maps810/samples/mapbuilder/index.html