本文整理汇总了Java中org.jdesktop.swingx.mapviewer.GeoPosition类的典型用法代码示例。如果您正苦于以下问题:Java GeoPosition类的具体用法?Java GeoPosition怎么用?Java GeoPosition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeoPosition类属于org.jdesktop.swingx.mapviewer包,在下文中一共展示了GeoPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buscaEndereco
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
public void buscaEndereco(final String rua, final Integer numero, final String cidade, final String uf) {
GeoPosition posicao = null;
try {
if (rua != null && cidade != null && uf != null) {
System.out.println("Buscando endereço:" + rua.trim() + ", " + ( numero != null ? numero.toString() : 0 ) + "-" + cidade.trim() + "-" + uf);
posicao = GeoUtil.getPositionForAddress(StringFunctions.clearAccents(rua).trim() + ", " + ( numero != null ? numero.toString() : 0 ), StringFunctions.clearAccents(cidade).trim(), uf);
}
else {
System.out.println("Não foi possível processar o endereço!\nRua, Cidade ou estado, inválidos!");
}
setAddressLocation(posicao);
}
catch (Exception e) {
System.out.println("Erro ao processar o endereço!\n" + e.getMessage());
e.printStackTrace();
}
}
示例2: geoToPixel
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
@Override
public Point2D geoToPixel(GeoPosition c, int zoom)
{
// calc the pixels per degree
Dimension mapSizeInTiles = getMapSize(zoom);
// double size_in_tiles = (double)getInfo().getMapWidthInTilesAtZoom(zoom);
// double size_in_tiles = Math.pow(2, getInfo().getTotalMapZoom() - zoom);
double size_in_pixels = mapSizeInTiles.getWidth() * getInfo().getTileSize(zoom);
double ppd = size_in_pixels / 360;
// the center of the world
double centerX = this.getTileSize(zoom) * mapSizeInTiles.getWidth() / 2;
double centerY = this.getTileSize(zoom) * mapSizeInTiles.getHeight() / 2;
double x = c.getLongitude() * ppd + centerX;
double y = -c.getLatitude() * ppd + centerY;
return new Point2D.Double(x, y);
}
示例3: pixelToGeo
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
@Override
public GeoPosition pixelToGeo(Point2D pix, int zoom)
{
// calc the pixels per degree
Dimension mapSizeInTiles = getMapSize(zoom);
double size_in_pixels = mapSizeInTiles.getWidth() * getInfo().getTileSize(zoom);
double ppd = size_in_pixels / 360;
// the center of the world
double centerX = this.getTileSize(zoom) * mapSizeInTiles.getWidth() / 2;
double centerY = this.getTileSize(zoom) * mapSizeInTiles.getHeight() / 2;
double lon = (pix.getX() - centerX) / ppd;
double lat = -(pix.getY() - centerY) / ppd;
return new GeoPosition(lat, lon);
}
示例4: setDefaultProvider
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
/**
* @param prov the default provider
*/
public void setDefaultProvider(DefaultProviders prov)
{
DefaultProviders old = this.defaultProvider;
this.defaultProvider = prov;
if (prov == DefaultProviders.SwingLabsBlueMarble)
{
setTileFactory(new CylindricalProjectionTileFactory());
setZoom(3);
}
if (prov == DefaultProviders.OpenStreetMaps)
{
TileFactoryInfo info = new OSMTileFactoryInfo();
TileFactory tf = new DefaultTileFactory(info);
setTileFactory(tf);
setZoom(11);
setAddressLocation(new GeoPosition(51.5, 0));
}
firePropertyChange("defaultProvider", old, prov);
repaint();
}
示例5: getPlottable
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
@Override
public Plottable getPlottable()
{
if( isValid() && getMessageType() == FleetsyncMessageType.GPS )
{
GeoPosition position =
new GeoPosition( getLatitude(), getLongitude() );
Alias alias = mAliasList.getFleetsyncAlias( getFromID() );
return new Plottable( mTimeReceived, position, getFromID(), alias );
}
else
{
return null;
}
}
示例6: getMapViewSetting
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
public MapViewSetting getMapViewSetting(String name, GeoPosition position, int zoom)
{
MapViewSetting loc = mSettings.getMapViewSetting(name);
if(loc != null)
{
return loc;
}
else
{
MapViewSetting newLoc = new MapViewSetting(name, position, zoom);
addSetting(newLoc);
return newLoc;
}
}
示例7: positionAt
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
/**
* http://www.movable-type.co.uk/scripts/latlong.html
*
* @param position
* @param direction
* in degrees, clockwise from north
* @param distance
* in m
* @return
*/
public static GeoPosition positionAt(GeoPosition position,
double direction, double distance) {
distance /= 1000;
double bearing = Math.toRadians(direction);
double latitude1 = Math.toRadians(position.getLatitude());
double longitude1 = Math.toRadians(position.getLongitude());
double earthDistance = distance / EARTH_RADIUS_KM;
double latitude2 = Math.asin(Math.sin(latitude1)
* Math.cos(earthDistance) + Math.cos(latitude1)
* Math.sin(earthDistance) * Math.cos(bearing));
double longitude2 = longitude1
+ Math.atan2(
Math.sin(bearing) * Math.sin(earthDistance)
* Math.cos(latitude1), Math.cos(earthDistance)
- Math.sin(latitude1) * Math.sin(latitude2));
longitude2 = (longitude2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
return new GeoPosition(Math.toDegrees(latitude2),
Math.toDegrees(longitude2));
}
示例8: drawStreet
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
private void drawStreet(Graphics2D g, JXMapViewer map, MapPath street) {
int lastX = 0;
int lastY = 0;
boolean first = true;
for (MapNode node : street.getNodes()) {
GeoPosition position = nodeToPosition(node);
// convert geo-coordinate to world bitmap pixel
Point2D pt = map.getTileFactory().geoToPixel(position,
map.getZoom());
if (first) {
first = false;
} else {
g.drawLine(lastX, lastY, (int) pt.getX(), (int) pt.getY());
}
lastX = (int) pt.getX();
lastY = (int) pt.getY();
}
}
示例9: setActiveWaypoint
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
@Subscribe
public void setActiveWaypoint(MouseOverWaypoint mouseOverWaypoint) {
if (this.track != null
&& this.track.getId().equals(
mouseOverWaypoint.getTrack().getId())) {
GeoPosition geoPos = GeoUtil.toGeoPoint(mouseOverWaypoint
.getSelectedWayPoint());
Set<Waypoint> wps = this.waypointPainter.getWaypoints();
Set<SelectedWaypoint> selected = Sets.newHashSet(filter(wps,
SelectedWaypoint.class));
// TODO use binary search!?
SelectedWaypoint first = getFirst(selected, null);
if (first == null) {
wps.add(first = new SelectedWaypoint());
}
first.setPosition(geoPos);
first.setSelectedWayPoint(this.track,
mouseOverWaypoint.getSelectedWayPoint());
this.mapKit.getMainMap().repaint();
}
}
示例10: TerrainGoogleMapButtonActionPerformed
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
private void TerrainGoogleMapButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TerrainGoogleMapButtonActionPerformed
// TODO add your handling code here:
// TODO add your handling code here:
// TODO add your handling code here:
latitud = mapa.getCenterPosition().getLatitude();
longitud = mapa.getCenterPosition().getLongitude();
final int max = 18;
TileFactoryInfo info = new TileFactoryInfo(0,16,max, 256, true, true, "http://mt1.google.com/vt/lyrs=p", "x","y","z") {
public String getTileUrl(int x, int y, int zoom) {
zoom = max-zoom;
String temp = this.baseURL +"&x="+x+"&y="+y+"&z="+zoom+" ";
return temp;
}
};
info.setDefaultZoomLevel(mapa.getZoomSlider().getValue());
TileFactory tf = new DefaultTileFactory(info);
mapa.setTileFactory(tf);
mapa.setCenterPosition(new GeoPosition(latitud, longitud));
}
示例11: MapGoogleMapButtonActionPerformed
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
private void MapGoogleMapButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MapGoogleMapButtonActionPerformed
// TODO add your handling code here:
// TODO add your handling code here:
latitud = mapa.getCenterPosition().getLatitude();
longitud = mapa.getCenterPosition().getLongitude();
final int max = 18;
TileFactoryInfo info = new TileFactoryInfo(0,16,max, 256, true, true, "http://mt0.google.com/vt/", "x","y","z") {
public String getTileUrl(int x, int y, int zoom) {
zoom = max-zoom;
String url = this.baseURL +"&x="+x+"&y="+y+"&z="+zoom+"";
return url;
}
};
info.setDefaultZoomLevel(mapa.getZoomSlider().getValue());
TileFactory tf = new DefaultTileFactory(info);
mapa.setTileFactory(tf);
mapa.setCenterPosition(new GeoPosition(latitud, longitud));
}
示例12: HybridoGoogleMapButtonActionPerformed
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
private void HybridoGoogleMapButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HybridoGoogleMapButtonActionPerformed
// TODO add your handling code here:
latitud = mapa.getCenterPosition().getLatitude();
longitud = mapa.getCenterPosition().getLongitude();
try{
final int max = 18;
TileFactoryInfo info = new TileFactoryInfo(0,16,max, 256, true, true, "http://mt0.google.com/vt/lyrs=y", "x","y","z") {
public String getTileUrl(int x, int y, int zoom) {
zoom = max-zoom;
String temp = this.baseURL +"&x="+x+"&y="+y+"&z="+zoom+"";
return temp;
}
};
info.setDefaultZoomLevel(mapa.getZoomSlider().getValue());
TileFactory tf = new DefaultTileFactory(info);
mapa.setTileFactory(tf);
mapa.setCenterPosition(new GeoPosition(latitud, longitud));
}catch(Exception UHE){
JOptionPane.showMessageDialog(null, "'Se ha perdido la coneccion con el servidor de mapas de Google'", "Error 006: UnknownHostException", JOptionPane.ERROR_MESSAGE);
}
}
示例13: CycleMapActionPerformed
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
private void CycleMapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CycleMapActionPerformed
latitud = mapa.getCenterPosition().getLatitude();
longitud = mapa.getCenterPosition().getLongitude();
final int max = 18;
TileFactoryInfo info = new TileFactoryInfo(0,16,max, 256, true, true, "http://andy.sandbox.cloudmade.com/tiles/cycle", "x","y","z") {
public String getTileUrl(int x, int y, int zoom) {
zoom = max-zoom;
String temp = this.baseURL +"/"+zoom+"/"+x+"/"+y+".png";
return temp;
}
};
info.setDefaultZoomLevel(mapa.getZoomSlider().getValue());
TileFactory tf = new DefaultTileFactory(info);
mapa.setTileFactory(tf);
mapa.setCenterPosition(new GeoPosition(latitud, longitud));
}
示例14: tileArrobaHomeActionPerformed
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
private void tileArrobaHomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tileArrobaHomeActionPerformed
// TODO add your handling code here:
latitud = mapa.getCenterPosition().getLatitude();
longitud = mapa.getCenterPosition().getLongitude();
final int max = 18;
TileFactoryInfo info = new TileFactoryInfo(0,16,max, 256, true, true, "http://tah.openstreetmap.org/Tiles/tile", "x","y","z") {
public String getTileUrl(int x, int y, int zoom) {
zoom = max-zoom;
String temp = this.baseURL +"/"+zoom+"/"+x+"/"+y+".png";
return temp;
}
};
info.setDefaultZoomLevel(mapa.getZoomSlider().getValue());
TileFactory tf = new DefaultTileFactory(info);
mapa.setTileFactory(tf);
mapa.setCenterPosition(new GeoPosition(latitud, longitud));
}
示例15: mapaCallesActionPerformed
import org.jdesktop.swingx.mapviewer.GeoPosition; //导入依赖的package包/类
private void mapaCallesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mapaCallesActionPerformed
// TODO add your handling code here:
latitud = mapa.getCenterPosition().getLatitude();
longitud = mapa.getCenterPosition().getLongitude();
try{
final int max = 18;
TileFactoryInfo info = new TileFactoryInfo(0,16,max, 256, true, true, "http://tile.openstreetmap.org", "x","y","z") {
public String getTileUrl(int x, int y, int zoom) {
zoom = max-zoom;
String temp = this.baseURL +"/"+zoom+"/"+x+"/"+y+".png";
return temp;
}
};
info.setDefaultZoomLevel(mapa.getZoomSlider().getValue());
TileFactory tf = new DefaultTileFactory(info);
mapa.setTileFactory(tf);
mapa.setCenterPosition(new GeoPosition(latitud, longitud));
}catch(Exception UHE){
JOptionPane.showMessageDialog(null, "'Se ha perdido la coneccion con el servidor de mapas de Open Street Maps'", "Error 006: UnknownHostException", JOptionPane.ERROR_MESSAGE);
}
}