gov.nasa.worldwind.avlist.AVKey Java Examples

The following examples show how to use gov.nasa.worldwind.avlist.AVKey. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WWJPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Path createPath(final Color color) {
	final ShapeAttributes attrs = new BasicShapeAttributes();
	attrs.setEnableLighting(true);
	attrs.setOutlineMaterial(new Material(color));
	attrs.setInteriorMaterial(new Material(new Color(color.getRed(), color.getGreen(), color.getBlue(), 50), 50));
	attrs.setInteriorOpacity(0.3);
	attrs.setOutlineWidth(_mapLineThickness);
	attrs.setOutlineOpacity(0.7);
	final Path path = new Path();
	path.setExtrude(true);
	path.setAttributes(attrs);
	path.setVisible(true);
	path.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
	path.setPathType(AVKey.GREAT_CIRCLE);
	path.setFollowTerrain(true);
	return path;
}
 
Example #2
Source File: WmsHandler.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private LayerInfo createLayerInfo(WMSCapabilities caps, WMSLayerCapabilities layerCaps, WMSLayerStyle style) {
    // Create the layer info specified by the layer's capabilities entry and the selected style.

    LayerInfo linfo = new LayerInfo();
    linfo.caps = caps;
    linfo.params = new AVListImpl();
    linfo.params.setValue(AVKey.LAYER_NAMES, layerCaps.getName());
    if (style != null)
        linfo.params.setValue(AVKey.STYLE_NAMES, style.getName());
    String abs = layerCaps.getLayerAbstract();
    if (!WWUtil.isEmpty(abs))
        linfo.params.setValue(AVKey.LAYER_ABSTRACT, abs);

    linfo.params.setValue(AVKey.DISPLAY_NAME, makeTitle(caps, linfo));

    return linfo;
}
 
Example #3
Source File: BasicMercatorTiledImageLayer.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
public void run() {
    // TODO: check to ensure load is still needed

    final java.net.URL textureURL = this.layer.getDataFileStore().findFile(tile.getPath(), false);
    if (textureURL != null && !this.layer.isTextureExpired(tile, textureURL)) {
        if (this.layer.loadTexture(tile, textureURL)) {
            layer.getLevels().unmarkResourceAbsent(tile);
            this.layer.firePropertyChange(AVKey.LAYER, null, this);
            return;
        } else {
            // Assume that something's wrong with the file and delete it.
            this.layer.getDataFileStore().removeFile(textureURL);
            layer.getLevels().markResourceAbsent(tile);
            String message = Logging.getMessage("generic.DeletedCorruptDataFile", textureURL);
            Logging.logger().info(message);
        }
    }

    this.layer.downloadTexture(this.tile);
}
 
Example #4
Source File: WmsHandler.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private Object createComponent(WMSCapabilities caps, AVList params) {
    AVList configParams = params.copy(); // Copy to insulate changes from the caller.

    // Some wms servers are slow, so increase the timeouts and limits used by world wind's retrievers.
    configParams.setValue(AVKey.URL_CONNECT_TIMEOUT, 30000);
    configParams.setValue(AVKey.URL_READ_TIMEOUT, 30000);
    configParams.setValue(AVKey.RETRIEVAL_QUEUE_STALE_REQUEST_LIMIT, 60000);

    try {
        String factoryKey = getFactoryKeyForCapabilities(caps);
        Factory factory = (Factory) WorldWind.createConfigurationComponent(factoryKey);
        return factory.createFromConfigSource(caps, configParams);
    } catch (Exception e) {
        // Ignore the exception, and just return null.
    }

    return null;
}
 
Example #5
Source File: OSMMapnikLayer.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private static LevelSet makeLevels() {
    AVList params = new AVListImpl();

    params.setValue(AVKey.TILE_WIDTH, 256);
    params.setValue(AVKey.TILE_HEIGHT, 256);
    params.setValue(AVKey.DATA_CACHE_NAME, "Earth/OSM-Mercator/OpenStreetMap OpentopoMap");
    params.setValue(AVKey.SERVICE, "https://tile.openstreetmap.org/");
    params.setValue(AVKey.DATASET_NAME, "h");
    params.setValue(AVKey.FORMAT_SUFFIX, ".png");
    params.setValue(AVKey.NUM_LEVELS, 22);
    params.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
    params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new LatLon(Angle.fromDegrees(22.5d), Angle.fromDegrees(45d)));
    params.setValue(AVKey.SECTOR, new MercatorSector(-1.0, 1.0, Angle.NEG180, Angle.POS180));
    params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder());

    return new LevelSet(params);
}
 
Example #6
Source File: NwwUtilities.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
public static void addTooltipController( WorldWindow wwd ) {
    new ToolTipController(wwd){

        @Override
        public void selected( SelectEvent event ) {
            // Intercept the selected position and assign its display name
            // the position's data value.
            if (event.getTopObject() instanceof BasicMarkerWithInfo) {
                BasicMarkerWithInfo marker = (BasicMarkerWithInfo) event.getTopObject();
                String info = marker.getInfo();
                marker.setValue(AVKey.DISPLAY_NAME, info);
            }
            super.selected(event);
        }
    };
}
 
Example #7
Source File: OpenTopoLayer.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private static LevelSet makeLevels() {
    AVList params = new AVListImpl();

    params.setValue(AVKey.TILE_WIDTH, 256);
    params.setValue(AVKey.TILE_HEIGHT, 256);
    params.setValue(AVKey.DATA_CACHE_NAME, "Earth/OSM-Mercator/OpenStreetMap Mapnik");
    params.setValue(AVKey.SERVICE, "https://a.tile.opentopomap.org/");
    params.setValue(AVKey.DATASET_NAME, "h");
    params.setValue(AVKey.FORMAT_SUFFIX, ".png");
    params.setValue(AVKey.NUM_LEVELS, 22);
    params.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
    params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new LatLon(Angle.fromDegrees(22.5d), Angle.fromDegrees(45d)));
    params.setValue(AVKey.SECTOR, new MercatorSector(-1.0, 1.0, Angle.NEG180, Angle.POS180));
    params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder());

    return new LevelSet(params);
}
 
Example #8
Source File: OepnvkarteLayer.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private static LevelSet makeLevels() {
    AVList params = new AVListImpl();

    params.setValue(AVKey.TILE_WIDTH, 256);
    params.setValue(AVKey.TILE_HEIGHT, 256);
    params.setValue(AVKey.DATA_CACHE_NAME, "Earth/OSM-Mercator/Oepnvkarte");
    params.setValue(AVKey.SERVICE, "http://tile.memomaps.de/tilegen//");
    params.setValue(AVKey.DATASET_NAME, "h");
    params.setValue(AVKey.FORMAT_SUFFIX, ".png");
    params.setValue(AVKey.NUM_LEVELS, 22);
    params.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
    params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new LatLon(Angle.fromDegrees(22.5d), Angle.fromDegrees(45d)));
    params.setValue(AVKey.SECTOR, new MercatorSector(-1.0, 1.0, Angle.NEG180, Angle.POS180));
    params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder());

    return new LevelSet(params);
}
 
Example #9
Source File: HtmlScreenAnnotation.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
public HtmlScreenAnnotation build() {
    AnnotationAttributes defaultAttributes = new AnnotationAttributes();
    defaultAttributes.setCornerRadius(cornerRadius);
    defaultAttributes.setInsets(insets);
    defaultAttributes.setBackgroundColor(backgroundColor);
    defaultAttributes.setTextColor(textColor);
    defaultAttributes.setDrawOffset(drawOffset);
    defaultAttributes.setDistanceMinScale(.5);
    defaultAttributes.setDistanceMaxScale(2);
    defaultAttributes.setDistanceMinOpacity(.5);
    defaultAttributes.setLeaderGapWidth(14);

    HtmlScreenAnnotation sa = new HtmlScreenAnnotation(htmlText, position);
    sa.getAttributes().setDefaults(defaultAttributes);
    sa.getAttributes().setSize(size);
    sa.getAttributes().setAdjustWidthToText(AVKey.SIZE_FIXED);
    sa.getAttributes().setHighlightScale(hightlightScale);

    return sa;
}
 
Example #10
Source File: LayerManagerPanel.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
protected void fill(WorldWindow wwd)
{
    // Populate this layer manager with an entry for each layer in the WorldWindow's layer list.

    if (this.isUpToDate(wwd))
        return;

    // First remove all the existing entries.
    this.layerPanels.clear();
    this.layerNamesPanel.removeAll();

    // Fill the layers panel with the titles of all layers in the world window's current model.
    for (Layer layer : wwd.getModel().getLayers())
    {
        if (layer.getValue(AVKey.IGNORE) != null)
            continue;

        GeneralLayerPanel layerPanel = new GeneralLayerPanel(wwd, layer);
        this.layerNamesPanel.add(layerPanel);
        this.layerPanels.add(layerPanel);
    }

    this.updateLayerActivity(wwd);
}
 
Example #11
Source File: WWJPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Create Annotation graphical Attributes
 *
 * @param selected if the annotation is selected
 * @param image
 * @param text
 * @return the attributes
 */
private static AnnotationAttributes createAnnotationAttr(final boolean selected, final ImageIcon image, final String text) {
	final String normalizedText = text == null || text.length() == 0 ? " " : text;
	final AnnotationAttributes attrs = new AnnotationAttributes();
	attrs.setAdjustWidthToText(AVKey.SIZE_FIT_TEXT);
	attrs.setFrameShape(AVKey.SHAPE_RECTANGLE);
	attrs.setDrawOffset(new Point(0, 10));
	attrs.setLeaderGapWidth(5);
	final Color color = getColor(selected);
	attrs.setTextColor(color);
	attrs.setBackgroundColor(new Color(1f, 1f, 1f, selected ? 1f : 0.5f));
	attrs.setBorderColor(color);
	attrs.setTextAlign(AVKey.CENTER);
	attrs.setInsets(new Insets(5, 15, 28, 15));
	attrs.setHighlighted(selected);
	attrs.setImageOpacity(1);
	int w = normalizedText.length() * 3;
	if (normalizedText.equals("*")) {
		w = 28;
	}
	attrs.setImageOffset(new Point(w, 17));
	// attrs.setImageScale(0.5);
	attrs.setImageSource(Util.toBufferedImage(image));
	attrs.setImageRepeat(AVKey.REPEAT_NONE);
	return attrs;
}
 
Example #12
Source File: LayerManagerPanel.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loops through this layer panel's layer/checkbox list and updates the checkbox font to indicate whether the
 * corresponding layer was just rendered. This method is called by a rendering listener -- see comment below.
 *
 * @param wwd the world window.
 */
protected void updateLayerActivity(WorldWindow wwd)
{
    for (GeneralLayerPanel layerPanel : this.layerPanels)
    {
        // The frame timestamp from the layer indicates the last frame in which it rendered something. If that
        // timestamp matches the current timestamp of the scene controller, then the layer rendered something
        // during the most recent frame. Note that this frame timestamp protocol is only in place by default
        // for TiledImageLayer and its subclasses. Applications could, however, implement it for the layers
        // they design.

        Long layerTimeStamp = (Long) layerPanel.getLayer().getValue(AVKey.FRAME_TIMESTAMP);
        Long frameTimeStamp = (Long) wwd.getSceneController().getValue(AVKey.FRAME_TIMESTAMP);

        if (layerTimeStamp != null && frameTimeStamp != null
            && layerTimeStamp.longValue() == frameTimeStamp.longValue())
        {
            // Set the font to bold if the layer was just rendered.
            layerPanel.setLayerNameFont(this.boldFont);
        }
        else if (layerPanel.getLayer() instanceof TiledImageLayer)
        {
            // Set the font to plain if the layer was not just rendered.
            layerPanel.setLayerNameFont(this.plainFont);
        }
        else if (layerPanel.getLayer().isEnabled())
        {
            // Set enabled layer types other than TiledImageLayer to bold.
            layerPanel.setLayerNameFont(this.boldFont);
        }
        else if (!layerPanel.getLayer().isEnabled())
        {
            // Set disabled layer types other than TiledImageLayer to plain.
            layerPanel.setLayerNameFont(this.plainFont);
        }
    }
}
 
Example #13
Source File: ViewControlsLayer.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get the control type associated with the given object or null if unknown.
 *
 * @param control the control object
 *
 * @return the control type. Can be one of {@link AVKey#VIEW_PAN}, {@link AVKey#VIEW_LOOK}, {@link
 *         AVKey#VIEW_HEADING_LEFT}, {@link AVKey#VIEW_HEADING_RIGHT}, {@link AVKey#VIEW_ZOOM_IN}, {@link
 *         AVKey#VIEW_ZOOM_OUT}, {@link AVKey#VIEW_PITCH_UP}, {@link AVKey#VIEW_PITCH_DOWN}, {@link
 *         AVKey#VIEW_FOV_NARROW} or {@link AVKey#VIEW_FOV_WIDE}. <p> Returns null if the object is not a view
 *         control associated with this layer. </p>
 */
public String getControlType(Object control)
{
    if (control == null || !(control instanceof ScreenAnnotation))
        return null;

    if (showPanControls && controlPan.equals(control))
        return AVKey.VIEW_PAN;
    else if (showLookControls && controlLook.equals(control))
        return AVKey.VIEW_LOOK;
    else if (showHeadingControls && controlHeadingLeft.equals(control))
        return AVKey.VIEW_HEADING_LEFT;
    else if (showHeadingControls && controlHeadingRight.equals(control))
        return AVKey.VIEW_HEADING_RIGHT;
    else if (showZoomControls && controlZoomIn.equals(control))
        return AVKey.VIEW_ZOOM_IN;
    else if (showZoomControls && controlZoomOut.equals(control))
        return AVKey.VIEW_ZOOM_OUT;
    else if (showPitchControls && controlPitchUp.equals(control))
        return AVKey.VIEW_PITCH_UP;
    else if (showPitchControls && controlPitchDown.equals(control))
        return AVKey.VIEW_PITCH_DOWN;
    else if (showFovControls && controlFovNarrow.equals(control))
        return AVKey.VIEW_FOV_NARROW;
    else if (showFovControls && controlFovWide.equals(control))
        return AVKey.VIEW_FOV_WIDE;
    else if (showVeControls && controlVeUp.equals(control))
        return AVKey.VERTICAL_EXAGGERATION_UP;
    else if (showVeControls && controlVeDown.equals(control))
        return AVKey.VERTICAL_EXAGGERATION_DOWN;

    return null;
}
 
Example #14
Source File: ViewControlsLayer.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a control image source.
 *
 * @param control the control type. Can be one of {@link AVKey#VIEW_PAN}, {@link AVKey#VIEW_LOOK}, {@link
 *                AVKey#VIEW_HEADING_LEFT}, {@link AVKey#VIEW_HEADING_RIGHT}, {@link AVKey#VIEW_ZOOM_IN}, {@link
 *                AVKey#VIEW_ZOOM_OUT}, {@link AVKey#VIEW_PITCH_UP}, {@link AVKey#VIEW_PITCH_DOWN}, {@link
 *                AVKey#VIEW_FOV_NARROW} or {@link AVKey#VIEW_FOV_WIDE}.
 *
 * @return the image source associated with the given control type.
 */
protected Object getImageSource(String control)
{
    if (control.equals(AVKey.VIEW_PAN))
        return IMAGE_PAN;
    else if (control.equals(AVKey.VIEW_LOOK))
        return IMAGE_LOOK;
    else if (control.equals(AVKey.VIEW_HEADING_LEFT))
        return IMAGE_HEADING_LEFT;
    else if (control.equals(AVKey.VIEW_HEADING_RIGHT))
        return IMAGE_HEADING_RIGHT;
    else if (control.equals(AVKey.VIEW_ZOOM_IN))
        return IMAGE_ZOOM_IN;
    else if (control.equals(AVKey.VIEW_ZOOM_OUT))
        return IMAGE_ZOOM_OUT;
    else if (control.equals(AVKey.VIEW_PITCH_UP))
        return IMAGE_PITCH_UP;
    else if (control.equals(AVKey.VIEW_PITCH_DOWN))
        return IMAGE_PITCH_DOWN;
    else if (control.equals(AVKey.VIEW_FOV_WIDE))
        return IMAGE_FOV_WIDE;
    else if (control.equals(AVKey.VIEW_FOV_NARROW))
        return IMAGE_FOV_NARROW;
    else if (control.equals(AVKey.VERTICAL_EXAGGERATION_UP))
        return IMAGE_VE_UP;
    else if (control.equals(AVKey.VERTICAL_EXAGGERATION_DOWN))
        return IMAGE_VE_DOWN;

    return null;
}
 
Example #15
Source File: WorldMap3DPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public WorldMap3DPanel(boolean flatEarth, boolean removeExtraLayers, PolygonsLayerModel polygonsLayerModel) {
    super(null, Configuration.getRequiredGLCapabilities(), new BasicGLCapabilitiesChooser());

    // create the default model as described in the current world wind properties
    Model model = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);

    setModel(model);
    if (flatEarth) {
        setFlatEarth();
    } else {
        setGlobeEarth();
    }

    this.selector = new Rectangle3DSelection(this.wwd) {
        @Override
        protected void setCursor(Cursor cursor) {
            WorldMap3DPanel.this.setCursor((cursor == null) ? WorldMapPanelWrapper.DEFAULT_CURSOR : cursor);
        }
    };
    this.selector.setInteriorColor(WorldMapPanelWrapper.SELECTION_FILL_COLOR);
    this.selector.setBorderColor(WorldMapPanelWrapper.SELECTION_BORDER_COLOR);
    this.selector.setBorderWidth(WorldMapPanelWrapper.SELECTION_LINE_WIDTH);
    this.selector.getLayer().setEnabled(true);

    LayerList layerList = this.wwd.getModel().getLayers();

    if (removeExtraLayers) {
        for (Layer layer : layerList) {
            if (layer instanceof CompassLayer || layer instanceof WorldMapLayer || layer instanceof StarsLayer
                    || layer instanceof LandsatI3WMSLayer || layer instanceof SkyGradientLayer) {

                layerList.remove(layer);
            }
        }
    }

    layerList.add(this.selector.getLayer());

    layerList.add(new Polygons3DLayer(polygonsLayerModel));
}
 
Example #16
Source File: AppPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public AppPanel(final WorldWindowGLCanvas shareWith, final boolean includeStatusBar, final boolean flatWorld,
                final boolean removeExtraLayers) {
    super(new BorderLayout());

    this.wwd = new WorldWindowGLCanvas(shareWith);

    // Create the default model as described in the current worldwind properties.
    final Model m = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
    this.wwd.setModel(m);
    if (flatWorld) {
        m.setGlobe(new EarthFlat());
        this.wwd.setView(new FlatOrbitView());
    } else {
        m.setGlobe(new Earth());
        this.wwd.setView(new BasicOrbitView());
    }

    if (removeExtraLayers) {
        final LayerList layerList = m.getLayers();
        for (Layer layer : layerList) {
            if (layer instanceof CompassLayer || layer instanceof WorldMapLayer || layer instanceof StarsLayer ||
                    layer instanceof LandsatI3WMSLayer || layer instanceof SkyGradientLayer)
                layerList.remove(layer);
        }
    }

    // Setup a select listener for the worldmap click-and-go feature
    this.wwd.addSelectListener(new ClickAndGoSelectListener(wwd, WorldMapLayer.class));

    this.wwd.getSceneController().setClutterFilter(new PlacemarkClutterFilter());

    this.add(this.wwd, BorderLayout.CENTER);

    if (includeStatusBar) {
        this.statusBar = new MinimalStatusBar();
        this.add(statusBar, BorderLayout.PAGE_END);
        this.statusBar.setEventSource(wwd);
    }
}
 
Example #17
Source File: DefaultProductLayer.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private PointPlacemark getLabelPlacemark(Position pos, String label) {
    PointPlacemarkAttributes ppmAtttrs = new PointPlacemarkAttributes();
    ppmAtttrs.setLabelOffset(new Offset(0.0, 0.0, AVKey.PIXELS, AVKey.PIXELS));
    ppmAtttrs.setScale(0.0);

    PointPlacemark ppm = new PointPlacemark(pos);
    ppm.setAttributes(ppmAtttrs);
    ppm.setLabelText(label);
    return ppm;
}
 
Example #18
Source File: BasicMercatorTiledImageLayer.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public BasicMercatorTiledImageLayer( LevelSet levelSet ) {
    super(levelSet);

    if (!WorldWind.getMemoryCacheSet().containsCache(MercatorTextureTile.class.getName())) {
        long size = Configuration.getLongValue(AVKey.TEXTURE_IMAGE_CACHE_SIZE, 3000000L);
        MemoryCache cache = new BasicMemoryCache((long) (0.85 * size), size);
        cache.setName("Texture Tiles");
        WorldWind.getMemoryCacheSet().addCache(MercatorTextureTile.class.getName(), cache);
    }
}
 
Example #19
Source File: Env.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Set the value of the field proxyPort
 * @param proxyPort the new proxyPort to set
 */
public void setProxyPort(final String proxyPort) {
	_proxyPort = proxyPort;
	if (proxyPort == null || "".equals(proxyPort)) {
		Configuration.removeKey(AVKey.URL_PROXY_PORT);
		Configuration.removeKey(AVKey.URL_PROXY_TYPE);
		System.getProperties().remove("http.proxyPort");
	} else {
		Configuration.setValue(AVKey.URL_PROXY_PORT, proxyPort);
		Configuration.setValue(AVKey.URL_PROXY_TYPE, Proxy.Type.HTTP);
		System.setProperty("http.proxyPort", proxyPort);
	}
}
 
Example #20
Source File: UTMCoord.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
public String toString()
{
    StringBuilder sb = new StringBuilder();
    sb.append(zone);
    sb.append(" ").append(AVKey.NORTH.equals(hemisphere) ? "N" : "S");
    sb.append(" ").append(easting).append("E");
    sb.append(" ").append(northing).append("N");
    return sb.toString();
}
 
Example #21
Source File: UPSCoordConverter.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * The function Convert_UPS_To_Geodetic converts UPS (hemisphere, easting, and northing) coordinates to geodetic
 * (latitude and longitude) coordinates according to the current ellipsoid parameters.  If any errors occur, the
 * error code(s) are returned by the function, otherwise UPS_NO_ERROR is returned.
 *
 * @param Hemisphere Hemisphere, either {@link gov.nasa.worldwind.avlist.AVKey#NORTH} or {@link
 *                   gov.nasa.worldwind.avlist.AVKey#SOUTH}.
 * @param Easting    Easting/X in meters
 * @param Northing   Northing/Y in meters
 *
 * @return error code
 */
public long convertUPSToGeodetic(String Hemisphere, double Easting, double Northing)
{
    long Error_Code = UPS_NO_ERROR;

    if (!AVKey.NORTH.equals(Hemisphere) && !AVKey.SOUTH.equals(Hemisphere))
        Error_Code |= UPS_HEMISPHERE_ERROR;
    if ((Easting < MIN_EAST_NORTH) || (Easting > MAX_EAST_NORTH))
        Error_Code |= UPS_EASTING_ERROR;
    if ((Northing < MIN_EAST_NORTH) || (Northing > MAX_EAST_NORTH))
        Error_Code |= UPS_NORTHING_ERROR;

    if (AVKey.NORTH.equals(Hemisphere))
        UPS_Origin_Latitude = MAX_ORIGIN_LAT;
    if (AVKey.SOUTH.equals(Hemisphere))
        UPS_Origin_Latitude = -MAX_ORIGIN_LAT;

    if (Error_Code == UPS_NO_ERROR)
    {   /*  no errors   */
        polarConverter.setPolarStereographicParameters(UPS_a,
            UPS_f,
            UPS_Origin_Latitude,
            UPS_Origin_Longitude,
            UPS_False_Easting,
            UPS_False_Northing);

        polarConverter.convertPolarStereographicToGeodetic(Easting, Northing);
        Latitude = polarConverter.getLatitude();
        Longitude = polarConverter.getLongitude();

        if ((Latitude < 0) && (Latitude > MIN_SOUTH_LAT))
            Error_Code |= UPS_LAT_ERROR;
        if ((Latitude >= 0) && (Latitude < MIN_NORTH_LAT))
            Error_Code |= UPS_LAT_ERROR;
    }
    return Error_Code;
}
 
Example #22
Source File: CoordinatesParser.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
private static GeoPoint parseUtmTokens(List<Token> tokens) throws IllegalArgumentException {
    int zone = 0;
    String hemisphere = null;
    double easting = Double.NaN;
    double northing = Double.NaN;
    for (Token token : tokens) {
        if (token.t == Type.UTM_ZONE) {
            zone = Integer.valueOf(token.c.substring(0, token.c.length() - 1));
            hemisphere = token.c.substring(token.c.length() - 1, token.c.length());
            if ("N".equals(hemisphere))
                hemisphere = AVKey.NORTH;
            if ("S".equals(hemisphere))
                hemisphere = AVKey.SOUTH;
        }
        if (token.t == Type.UTM_EASTING) {
            easting = Double.valueOf(token.c);
        }
        if (token.t == Type.UTM_NORTHING) {
            northing = Double.valueOf(token.c);
        }
    }
    if (zone == 0 || Double.isNaN(easting) || Double.isNaN(northing))
        throw new IllegalArgumentException("Wrong UTM coordinates format");

    UTMCoord coord = UTMCoord.fromUTM(zone, hemisphere, easting, northing);
    return new GeoPoint(coord.getLatitude().degrees, coord.getLongitude().degrees);
}
 
Example #23
Source File: ToolTipAnnotation.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
protected void initializeAttributes()
{
    this.attributes.setAdjustWidthToText(AVKey.SIZE_FIT_TEXT);
    this.attributes.setFrameShape(AVKey.SHAPE_RECTANGLE);
    this.attributes.setTextColor(Color.BLACK);
    this.attributes.setBackgroundColor(new Color(1f, 1f, 1f, 0.8f));
    this.attributes.setCornerRadius(5);
    this.attributes.setBorderColor(new Color(0xababab));
    this.attributes.setFont(Font.decode("Arial-PLAIN-12"));
    this.attributes.setTextAlign(AVKey.CENTER);
    this.attributes.setInsets(new Insets(5, 5, 5, 5));
}
 
Example #24
Source File: ToolTipsUtils.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public static void addTooltipController(WorldWindow wwd) {
    new ToolTipController(wwd) {

        @Override
        public void selected(SelectEvent event) {
            if (event.getTopObject() instanceof BasicMarkerWithInfo) {
                BasicMarkerWithInfo marker = (BasicMarkerWithInfo) event.getTopObject();
                String info = marker.getInfo();
                marker.setValue(AVKey.DISPLAY_NAME, info);
            }
            super.selected(event);
        }
    };
}
 
Example #25
Source File: SectorSelector.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
protected RegionShape(Sector sector) {
    super(sector);

    // Create the default border shape.
    this.setBorder(new SurfaceSector(sector));

    // The edges of the region shape should be constant lines of latitude and longitude.
    this.setPathType(AVKey.LINEAR);
    this.getBorder().setPathType(AVKey.LINEAR);

    // Setup default interior rendering attributes. Note that the interior rendering attributes are
    // configured so only the SurfaceSector's interior is rendered.
    ShapeAttributes interiorAttrs = new BasicShapeAttributes();
    interiorAttrs.setDrawOutline(false);
    interiorAttrs.setInteriorMaterial(new Material(Color.WHITE));
    interiorAttrs.setInteriorOpacity(0.1);
    this.setAttributes(interiorAttrs);
    this.setHighlightAttributes(interiorAttrs);

    // Setup default border rendering attributes. Note that the border rendering attributes are configured
    // so that only the SurfaceSector's outline is rendered.
    ShapeAttributes borderAttrs = new BasicShapeAttributes();
    borderAttrs.setDrawInterior(false);
    borderAttrs.setOutlineMaterial(new Material(Color.RED));
    borderAttrs.setOutlineOpacity(0.7);
    borderAttrs.setOutlineWidth(3);
    this.getBorder().setAttributes(borderAttrs);
    this.getBorder().setHighlightAttributes(borderAttrs);
}
 
Example #26
Source File: WmsHandler.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
private String getFactoryKeyForCapabilities(WMSCapabilities caps) {
    boolean hasApplicationBilFormat = false;

    Set<String> formats = caps.getImageFormats();
    for (String s : formats) {
        if (s.contains("application/bil")) {
            hasApplicationBilFormat = true;
            break;
        }
    }

    return hasApplicationBilFormat ? AVKey.ELEVATION_MODEL_FACTORY : AVKey.LAYER_FACTORY;
}
 
Example #27
Source File: UPSCoord.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
public String toString()
{
    StringBuilder sb = new StringBuilder();
    sb.append(AVKey.NORTH.equals(hemisphere) ? "N" : "S");
    sb.append(" ").append(easting).append("E");
    sb.append(" ").append(northing).append("N");
    return sb.toString();
}
 
Example #28
Source File: WmsHandler.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
private String makeTitle(WMSCapabilities caps, LayerInfo layerInfo) {
    String layerNames = layerInfo.params.getStringValue(AVKey.LAYER_NAMES);
    String styleNames = layerInfo.params.getStringValue(AVKey.STYLE_NAMES);
    String[] lNames = layerNames.split(",");
    String[] sNames = styleNames != null ? styleNames.split(",") : null;

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < lNames.length; i++) {
        if (sb.length() > 0)
            sb.append(", ");

        String layerName = lNames[i];
        WMSLayerCapabilities lc = caps.getLayerByName(layerName);
        String layerTitle = lc.getTitle();
        sb.append(layerTitle != null ? layerTitle : layerName);

        if (sNames == null || sNames.length <= i)
            continue;

        String styleName = sNames[i];
        WMSLayerStyle style = lc.getStyleByName(styleName);
        if (style == null)
            continue;

        sb.append(" : ");
        String styleTitle = style.getTitle();
        sb.append(styleTitle != null ? styleTitle : styleName);
    }

    return sb.toString();
}
 
Example #29
Source File: Env.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Set the value of the field proxyHost
 * @param proxyHost the new proxyHost to set
 */
public void setProxyHost(final String proxyHost) {
	_proxyHost = proxyHost;
	if (proxyHost == null || "".equals(proxyHost)) {
		Configuration.removeKey(AVKey.URL_PROXY_HOST);
		Configuration.removeKey(AVKey.URL_PROXY_TYPE);
		System.getProperties().remove("http.proxyHost");
	} else {
		Configuration.setValue(AVKey.URL_PROXY_HOST, proxyHost);
		Configuration.setValue(AVKey.URL_PROXY_TYPE, Proxy.Type.HTTP);
		System.setProperty("http.proxyHost", proxyHost);
	}
}
 
Example #30
Source File: NwwPanel.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
protected NwwPanel( boolean useWwGlCanvas, boolean withStatusBar, boolean removeDefaultLayers ) {
    super(new BorderLayout());

    // Configuration.setValue(AVKey.INITIAL_LATITUDE, gpsLogShps[0].y);
    // Configuration.setValue(AVKey.INITIAL_LONGITUDE, gpsLogShps[0].x);
    // Configuration.setValue(AVKey.INITIAL_ALTITUDE, 1000);
    // Configuration.setValue(AVKey.INITIAL_PITCH, 45);

    long t1 = System.currentTimeMillis();
    if (useWwGlCanvas) {
        logger.insertDebug("NwwPanel", "Create GLCanvas");
        wwd = new WorldWindowGLCanvas();
    } else {
        logger.insertDebug("NwwPanel", "Create GLJPanel");
        wwd = new WorldWindowGLJPanel();
    }
    // ((Component) wwd).setPreferredSize(new Dimension(500, 500));
    long t2 = System.currentTimeMillis();
    logger.insertDebug("NwwPanel", "Create Canvas - DONE " + (t2 - t1) / 1000);

    logger.insertDebug("NwwPanel", "Create Model");
    Model model = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
    wwd.setModel(model);
    long t3 = System.currentTimeMillis();
    logger.insertDebug("NwwPanel", "Create Model - DONE " + (t3 - t2) / 1000);

    if (removeDefaultLayers) {
        logger.insertDebug("NwwPanel", "Remove and add layers");
        LayerList layers = model.getLayers();
        List<Layer> addBack = new ArrayList<>();
        Iterator<Layer> layerIterator = layers.iterator();
        List<String> namesToKeep = NwwUtilities.LAYERS_TO_KEEP_FROM_ORIGNALNWW;
        while( layerIterator.hasNext() ) {
            Layer layer = layerIterator.next();
            if (namesToKeep.contains(layer.getName())) {
                addBack.add(layer);
            }
        }
        layers.clear();
        layers.addAll(addBack);
        long t4 = System.currentTimeMillis();
        logger.insertDebug("NwwPanel", "Remove and add layers - DONE " + (t4 - t3) / 1000);
    }
    this.add((Component) wwd, BorderLayout.CENTER);

    if (withStatusBar) {
        this.statusBar = new StatusBar();
        this.add(statusBar, BorderLayout.PAGE_END);
        this.statusBar.setEventSource(getWwd());
    }
}