| Programming with JViews Maps > Creating a Map Application Using the API > Creating Data Source Objects > Vector Data Sources |
Vector Data Sources |
INDEX
PREVIOUS
NEXT
|
This section describes how to create data source objects for:
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-maps81/samples/shape/index.html
To load a shapefile using tiling, use the following code:
IlvTiledShapeDataSource tiledSource = new IlvTiledShapeDataSource(shpFileName,true);
If the shape file 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);
To load a shapefile without using tiling, use the following code:
IlvShapeDataSource shpDataSource = new IlvShapeDataSource(shpFileName, true);
To create a MID/MIF data source, use the following code:
IlvMapDataSource source = new IlvMIDMIFDataSource(fileName); source.setManager(getView().getManager());
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);
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 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 setup the transformation you want to use to read DXF.
If you want to transform the DXF extent into the latitude/longitude range provided:
source.setDestinationBounds(lonMinRad,latMinRad,lonMaxRad,latMaxRad);
or
If you want to use a more complex transformation (such as reprojection):
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 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 Table 3.1:
KML files can refer to other files, either locally or through a network link URL. KMZ is a zipped 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 (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 maps SVG reader is based on features in ILOG JViews Framework. These features are described in Scalable Vector Graphics.
The maps SVG reader ignores the following SVG elements:
All the other elements, including text elements, are transformed into IlvMapGeneralPath instances.
The graphic styles in the resulting map are renderedto 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 a SVG data source, use the following code:
IlvSVGDataSource source = new IlvSVGDataSource("C:/maps/SVG/maps.svg");
source.setManager(getView().getManager());
You then need to setup 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-maps81/samples/mapbuilder/index.html
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |