Hi!
I'm just starting with VisAd and i cant resolve (understand) this
little problem.
I tried to create a world based on an mcidas base map (no problem with
that, very simple of course) and now i want to plot some lines on it,
like travel routes, i do plot the lines but they do not "curve" to the
earth, they just go throw it. Probably it's something very simple but as
i said i'm really starting with visAd.
Here is the code:
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.*;
import visad.*;
import visad.ColorControl;
import visad.CoordinateSystem;
import visad.ConstantMap;
import visad.Data;
import visad.DataReference;
import visad.DataReferenceImpl;
import visad.Display;
import visad.DisplayImpl;
import visad.FieldImpl;
import visad.FlatField;
import visad.FunctionType;
import visad.Linear2DSet;
import visad.RealTupleType;
import visad.RealType;
import visad.ScalarMap;
import visad.data.mcidas.AreaAdapter;
import visad.data.mcidas.BaseMapAdapter;
import visad.java3d.DisplayImplJ3D;
import visad.java3d.TwoDDisplayRendererJ3D;
public class TravelRoute
{
private DisplayImpl display;
public TravelRoute(String mapFile)
{
try
{
ScalarMap latMap;
ScalarMap lonMap;
display = new DisplayImplJ3D("display");
latMap = new ScalarMap(RealType.Latitude, Display.Latitude);
lonMap = new ScalarMap(RealType.Longitude, Display.Longitude);
display.addMap(latMap);
display.addMap(lonMap);
latMap.setRange(-90.0, 90.0);
lonMap.setRange(-180.0, 180.0);
BaseMapAdapter baseMapAdapter = new BaseMapAdapter(mapFile);
DataReference coastlinesRef = new
DataReferenceImpl("CoastLines");
coastlinesRef.setData(baseMapAdapter.getData());
ConstantMap[] coastlinesConstantMap = new ConstantMap[4];
coastlinesConstantMap[0] = new ConstantMap(1., Display.Blue);
coastlinesConstantMap[1] = new ConstantMap(1., Display.Red);
coastlinesConstantMap[2] = new ConstantMap(1., Display.Green);
coastlinesConstantMap[3] = new ConstantMap(1.001,
Display.Radius);
RealTupleType earth = new RealTupleType(RealType.Latitude,
RealType.Longitude);
float[][] points1 = {{50.0f, 2.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 0.0f}};
Gridded2DSet route1 = new Gridded2DSet(earth, points1, 4);
float[][] points2 = {{3.0f, 2.0f, 1.0f},
{2.0f, 1.0f, 0.0f}};
Gridded2DSet route2 = new Gridded2DSet(earth, points2, 3);
float[][] points3 = {{40.0f, 3.0f, 2.0f},
{-2.0f, -1.0f, 0.0f}};
Gridded2DSet route3 = new Gridded2DSet(earth, points3, 3);
Gridded2DSet[] route_system = {route1, route2, route3};
UnionSet routes = new UnionSet(earth, route_system);
DataReference routeslinesRef = new DataReferenceImpl("routes");
routeslinesRef.setData(routes);
ConstantMap[] routeslinesConstantMap = new ConstantMap[4];
routeslinesConstantMap[0] = new ConstantMap(0., Display.Blue);
routeslinesConstantMap[1] = new ConstantMap(1., Display.Red);
routeslinesConstantMap[2] = new ConstantMap(0., Display.Green);
routeslinesConstantMap[3] = new ConstantMap(1.000,
Display.Radius);
display.disableAction();
display.addReference(routeslinesRef, routeslinesConstantMap);
display.addReference(coastlinesRef, coastlinesConstantMap);
display.enableAction();
}
catch (Exception ne)
{
ne.printStackTrace();
System.exit(1);
}
}
public static void main (String[] args) {
String mapFile = "/usr/people/simoes/Training/teste/data/OUTLSUPW";
JFrame frame = new JFrame("Travel Routes");
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
TravelRoute Routes = new TravelRoute(mapFile);
frame.getContentPane().add(Routes.display.getComponent());
frame.setSize(500, 500);
frame.setVisible(true);
}
}
Ps. Ane tips for a newbie? :)
Thanks in advance,
Tiago Simoes
KNMI, NL