/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package _org.geoforge.amd.wwwx.examples;
import gov.nasa.worldwind.Configuration;
import gov.nasa.worldwind.WorldWind;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.layers.RenderableLayer;
import gov.nasa.worldwind.render.BasicShapeAttributes;
import gov.nasa.worldwind.render.Material;
import gov.nasa.worldwind.render.Path;
import gov.nasa.worldwind.render.ShapeAttributes;
import gov.nasa.worldwindx.examples.ApplicationTemplate;
import gov.nasa.worldwindx.examples.util.DirectedPath;
import java.util.ArrayList;
/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com ... please remove "_AT_" from the above
* string to get the right email address
*/
public class GfrPathsWithDirection extends ApplicationTemplate
{
public static class AppFrame extends ApplicationTemplate.AppFrame
{
public AppFrame()
{
super(true, true, false);
RenderableLayer layer = new RenderableLayer();
// Create and set an attribute bundle.
ShapeAttributes attrs = new BasicShapeAttributes();
attrs.setOutlineMaterial(Material.RED);
attrs.setOutlineWidth(2d);
// Create a path, set some of its properties and set its attributes.
ArrayList<Position> pathPositions = new ArrayList<Position>();
/*pathPositions.add(Position.fromDegrees(49.01653274909177, -122.7349081128505, 1));
pathPositions.add(Position.fromDegrees(49.01715024535254, -122.7596194200486, 10));
pathPositions.add(Position.fromDegrees(49.02781845803761, -122.7651733463364, 100));*/
pathPositions.add(Position.fromDegrees(41.5438, 2.4430, 0));
pathPositions.add(Position.fromDegrees(41.58955, 2.4677, 0));
/*pathPositions.add(Position.fromDegrees(49.09727187849899, -122.8187118695457, 1000));
pathPositions.add(Position.fromDegrees(49.1002974270654, -122.7348314826556, 100));
pathPositions.add(Position.fromDegrees(49.11190305133165, -122.7345541413842, 100));
pathPositions.add(Position.fromDegrees(49.11101764617014, -122.7455553490629, 10));
pathPositions.add(Position.fromDegrees(49.11509767012883, -122.7459193678911, 10));
pathPositions.add(Position.fromDegrees(49.11467371318521, -122.7563706291131, 10));*/
Path path = new DirectedPath(pathPositions);
//SurfacePolyline path = new SurfacePolyline();
// To ensure that the arrowheads resize smoothly, refresh each time the path is drawn.
path.setAttributes(attrs);
path.setVisible(true);
path.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
path.setFollowTerrain(true);
/*path.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);*/
path.setPathType(AVKey.GREAT_CIRCLE);
layer.addRenderable(path);
// Add the layer to the model.
insertBeforeCompass(getWwd(), layer);
// Update layer panel
this.getLayerPanel().update(this.getWwd());
}
}
public static void main(String[] args)
{
Configuration.setValue(AVKey.INITIAL_LATITUDE, 49.06);
Configuration.setValue(AVKey.INITIAL_LONGITUDE, -122.77);
Configuration.setValue(AVKey.INITIAL_ALTITUDE, 22000);
ApplicationTemplate.start("World Wind Paths With Direction", AppFrame.class);
}
}