gov.nasa.worldwind.geom.LatLon Java Examples

The following examples show how to use gov.nasa.worldwind.geom.LatLon. 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: 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 #2
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 #3
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 #4
Source File: NwwUtilities.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public static LatLon getEnvelopeCenter( Envelope bounds ) {
    Coordinate centre = bounds.centre();
    LatLon latLon = new LatLon(Angle.fromDegrees(centre.y), Angle.fromDegrees(centre.x));
    return latLon;
}
 
Example #5
Source File: NwwUtilities.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public static LatLon toLatLon( double lat, double lon ) {
    LatLon latLon = new LatLon(Angle.fromDegrees(lat), Angle.fromDegrees(lon));
    return latLon;
}
 
Example #6
Source File: NwwUtilities.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public static Position toPosition( double lat, double lon, double elev ) {
    LatLon latLon = toLatLon(lat, lon);
    return new Position(latLon, elev);
}
 
Example #7
Source File: MapsforgeNwwLayer.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
private static LevelSet makeLevels(String layerName, OsmTilegenerator osmTilegenerator, Integer tileSize)
		throws MalformedURLException {
	AVList params = new AVListImpl();
	String cacheRelativePath = "mapsforge/" + layerName + "-tiles";

	if (tileSize == null || tileSize < 256) {
		tileSize = TILESIZE;
	}

	int finalTileSize = tileSize;

	params.setValue(AVKey.URL, cacheRelativePath);
	params.setValue(AVKey.TILE_WIDTH, finalTileSize);
	params.setValue(AVKey.TILE_HEIGHT, finalTileSize);
	params.setValue(AVKey.DATA_CACHE_NAME, cacheRelativePath);
	params.setValue(AVKey.SERVICE, "*");
	params.setValue(AVKey.DATASET_NAME, "*");
	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));
	File cacheRoot = CacheUtils.getCacheRoot();
	final File cacheFolder = new File(cacheRoot, cacheRelativePath);
	if (!cacheFolder.exists()) {
		cacheFolder.mkdirs();
	}

	params.setValue(AVKey.TILE_URL_BUILDER, new TileUrlBuilder() {

		public URL getURL(Tile tile, String altImageFormat) throws MalformedURLException {
			int zoom = tile.getLevelNumber() + 3;
			Sector sector = tile.getSector();
			double north = sector.getMaxLatitude().degrees;
			double south = sector.getMinLatitude().degrees;
			double east = sector.getMaxLongitude().degrees;
			double west = sector.getMinLongitude().degrees;
			double centerX = west + (east - west) / 2.0;
			double centerY = south + (north - south) / 2.0;

			int[] tileNumber = NwwUtilities.getTileNumber(centerY, centerX, zoom);
			int x = tileNumber[0];
			int y = tileNumber[1];

			File tileImageFolderFile = new File(cacheFolder, zoom + File.separator + x);
			if (!tileImageFolderFile.exists()) {
				tileImageFolderFile.mkdirs();
			}
			File imgFile = new File(tileImageFolderFile, y + ".png");
			try {
				if (!imgFile.exists()) {
					BufferedImage bImg = osmTilegenerator.getImage(zoom, x, y);
					// PrintUtilities.printRenderedImageData(bImg);

					ImageIO.write(bImg, "png", imgFile);
				}
				return imgFile.toURI().toURL();
			} catch (IOException e) {
				return null;
			}
		}
	});

	return new LevelSet(params);
}
 
Example #8
Source File: GridCoverageNwwLayer.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
private static LevelSet makeLevels( File imsf, GTRenderer renderer, Integer tileSize, Color colorToMakeTransparent ) throws MalformedURLException {
    AVList params = new AVListImpl();
    if (tileSize == null || tileSize < 256) {
        tileSize = TILESIZE;
    }

    int finalTileSize = tileSize;

    String tilesPart = "-tiles";
    String cacheRelativePath = "imagemosaics/" + imsf.getName() + tilesPart;

    String urlString = imsf.toURI().toURL().toExternalForm();
    params.setValue(AVKey.URL, urlString);
    params.setValue(AVKey.TILE_WIDTH, finalTileSize);
    params.setValue(AVKey.TILE_HEIGHT, finalTileSize);
    params.setValue(AVKey.DATA_CACHE_NAME, cacheRelativePath);
    params.setValue(AVKey.SERVICE, "*");
    params.setValue(AVKey.DATASET_NAME, "*");

    final String imageFormat = "png";
    params.setValue(AVKey.FORMAT_SUFFIX, "." + imageFormat);
    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));
    File cacheRoot = CacheUtils.getCacheRoot();
    final File cacheFolder = new File(cacheRoot, cacheRelativePath);
    if (!cacheFolder.exists()) {
        cacheFolder.mkdirs();
    }

    params.setValue(AVKey.TILE_URL_BUILDER, new TileUrlBuilder(){

        public URL getURL( Tile tile, String altImageFormat ) throws MalformedURLException {
            int zoom = tile.getLevelNumber() + 3;
            Sector sector = tile.getSector();
            double north = sector.getMaxLatitude().degrees;
            double south = sector.getMinLatitude().degrees;
            double east = sector.getMaxLongitude().degrees;
            double west = sector.getMinLongitude().degrees;
            double centerX = west + (east - west) / 2.0;
            double centerY = south + (north - south) / 2.0;
            int[] tileNumber = NwwUtilities.getTileNumber(centerY, centerX, zoom);
            int x = tileNumber[0];
            int y = tileNumber[1];

            Rectangle imageBounds = new Rectangle(0, 0, finalTileSize, finalTileSize);
            BufferedImage image = new BufferedImage(imageBounds.width, imageBounds.height, BufferedImage.TYPE_INT_RGB);
            Graphics2D gr = image.createGraphics();
            gr.setPaint(Color.WHITE);
            gr.fill(imageBounds);
            gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

            try {
                synchronized (renderer) {
                    renderer.paint(gr, imageBounds,
                            new ReferencedEnvelope(west, east, south, north, DefaultGeographicCRS.WGS84));
                    File tileImageFolderFile = new File(cacheFolder, zoom + File.separator + x);
                    if (!tileImageFolderFile.exists()) {
                        tileImageFolderFile.mkdirs();
                    }
                    File imgFile = new File(tileImageFolderFile, y + ".png");
                    if (!imgFile.exists()) {
                        if (colorToMakeTransparent != null) {
                            image = ImageUtilities.makeColorTransparent(image, colorToMakeTransparent);
                        }
                        ImageIO.write(image, "png", imgFile);
                    }
                    return imgFile.toURI().toURL();
                }
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    });

    return new LevelSet(params);
}
 
Example #9
Source File: ViewControlsSelectListener.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
protected boolean isPathCrossingAPole(LatLon p1, LatLon p2)
{
    return Math.abs(p1.getLongitude().degrees - p2.getLongitude().degrees) > 20
        && Math.abs(p1.getLatitude().degrees - 90 * Math.signum(p1.getLatitude().degrees)) < 10;
}
 
Example #10
Source File: AppPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private static ElevationModel makeElevationModel() throws URISyntaxException, ParserConfigurationException,
        IOException, SAXException {
    final URI serverURI = new URI("http://www.nasa.network.com/elev");

    final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setNamespaceAware(true);
    if (Configuration.getJavaVersion() >= 1.6) {
        try {
            docBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
        } catch (ParserConfigurationException e) {   // Note it and continue on. Some Java5 parsers don't support the feature.
            String message = Logging.getMessage("XML.NonvalidatingNotSupported");
            Logging.logger().finest(message);
        }
    }
    final DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

    // Request the capabilities document from the server.
    final CapabilitiesRequest req = new CapabilitiesRequest(serverURI);
    final Document doc = docBuilder.parse(req.toString());

    // Parse the DOM as a capabilities document.
    // CHANGED
    //final Capabilities caps = Capabilities.parse(doc);
    final WMSCapabilities caps = new WMSCapabilities(doc);

    final double HEIGHT_OF_MT_EVEREST = 8850d; // meters
    final double DEPTH_OF_MARIANAS_TRENCH = -11000d; // meters

    // Set up and instantiate the elevation model
    final AVList params = new AVListImpl();
    params.setValue(AVKey.LAYER_NAMES, "|srtm3");
    params.setValue(AVKey.TILE_WIDTH, 150);
    params.setValue(AVKey.TILE_HEIGHT, 150);
    params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, LatLon.fromDegrees(20, 20));
    params.setValue(AVKey.NUM_LEVELS, 8);
    params.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
    params.setValue(AVKey.ELEVATION_MIN, DEPTH_OF_MARIANAS_TRENCH);
    params.setValue(AVKey.ELEVATION_MAX, HEIGHT_OF_MT_EVEREST);

    final CompoundElevationModel cem = new CompoundElevationModel();
    cem.addElevationModel(new WMSBasicElevationModel(caps, params));

    return cem;
}
 
Example #11
Source File: Util.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Distance between two points on the globe (in km)
 *
 * @param point1
 * @param point2
 * @param globe
 * @return
 */
public static int distance(final RoutePoint point1, final RoutePoint point2) {
	final LatLon ll1 = new LatLon(Angle.fromDegrees(point1.getLat()), Angle.fromDegrees(point1.getLon()));
	final LatLon ll2 = new LatLon(Angle.fromDegrees(point2.getLat()), Angle.fromDegrees(point2.getLon()));
	return (int) (Earth.WGS84_EQUATORIAL_RADIUS * LatLon.greatCircleDistance(ll1, ll2).getRadians() / 1000);
}