/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ import java.awt.Color; import java.io.IOException; import ilog.views.IlvManager; import ilog.views.maps.IlvCoordinateSystemProperty; import ilog.views.maps.IlvMapFeatureIterator; import ilog.views.maps.format.IlvMapFormatException; import ilog.views.maps.format.IlvMapLoader; import ilog.views.maps.format.shapefile.IlvShapeFileReader; import ilog.views.maps.projection.IlvMercatorProjection; import ilog.views.maps.projection.IlvProjection; import ilog.views.maps.rendering.IlvDefaultPointRenderer; import ilog.views.maps.rendering.IlvMapPointRenderingStyle; import ilog.views.maps.srs.coordsys.IlvGeographicCoordinateSystem; import ilog.views.maps.srs.coordsys.IlvProjectedCoordinateSystem; import ilog.views.util.IlvProductUtil; public class MapLoaderSample { public MapLoaderSample() { } public void sample1() { IlvManager manager = new IlvManager(); IlvMapLoader loader = new IlvMapLoader(manager); try { loader.load("data/myShapeFile.shp"); } catch (IlvMapFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void sample2() throws IOException { IlvManager manager = new IlvManager(); // 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 the map loader. IlvMapLoader mapLoader = new IlvMapLoader(manager); // Load a ShapeFile expressed in geographic coordinate system. mapLoader.setDefaultCoordinateSystem(IlvGeographicCoordinateSystem.WGS84); mapLoader.load("data/myShapeFile.shp"); } IlvMapFeatureIterator getFeatureIterator() { try { return new IlvShapeFileReader("data/myShapeFile.shp", null); } catch (IOException e) { e.printStackTrace(); return null; } } public void sample3() throws IOException { IlvManager manager = new IlvManager(); IlvMapFeatureIterator myIterator = getFeatureIterator(); IlvMapLoader mapLoader = new IlvMapLoader(manager); IlvDefaultPointRenderer renderer = new IlvDefaultPointRenderer(); IlvMapPointRenderingStyle style = new IlvMapPointRenderingStyle(); style.setMarkerColor(Color.green); style.setMarkerSize(4); renderer.setPointRenderingStyle(style); mapLoader.load(myIterator, renderer); System.out.println("Map loader loaded " + manager.getCardinal() + " points"); } static public void main(String args[]) { // This sample uses JViews Maps features. When deploying an // application that includes this code, you need to be in possession // of a Perforce JViews Maps Deployment license. IlvProductUtil.DeploymentLicenseRequired(IlvProductUtil.JViews_Maps_Deployment); try { new MapLoaderSample().sample3(); } catch (Exception e) { e.printStackTrace(); } } }