- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我从 Google Earth 中拍摄了一张图像,其所有 4 个角的纬度/经度都是已知的。我正在使用 GPS 传感器捕获纬度/经度。我必须使用java将这些捕获的纬度/经度转换为图像坐标(像素坐标)。我将使用图像坐标来模拟车辆在静态 map 上移动(图像取自 Google 地球)。
我找到了这个公式并尝试实现它
J = 输入经度K = 输入纬度
计算X像素
XPixel = CInt(((Y - J) / CDbl(Z)) * 1653)
计算 Y 像素
YPixel = CInt(((A - K) / CDbl(C)) * 1012)
这是我使用的代码。
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
public class LatLongService {
private static LatLongService latLangService;
private BufferedReader reader = null;
private String st;
private LatLongService() {
try {
reader = new BufferedReader(new FileReader(new File(
"resources/GPS_lat_long_2.txt")));
} catch (Exception e) {
e.printStackTrace();
}
}
public static LatLongService getInstance() {
if (latLangService == null)
latLangService = new LatLongService();
return latLangService;
}
public List<Point2D> readLatLongList() {
List<Point2D> pointList = new ArrayList<Point2D>();
StringBuffer xStr;
StringBuffer yStr = new StringBuffer();
try {
while ((st = reader.readLine()) != null) {
xStr = new StringBuffer(st.substring(0, st.indexOf(',')));
yStr = new StringBuffer(st.substring(st.indexOf(',') + 2,
st.length()));
Point2D pt = new Point2D.Double(
new Double(xStr.toString()).doubleValue(), new Double(
yStr.toString()).doubleValue());
pointList.add(pt);
}
} catch (Exception e) {
e.printStackTrace();
try {
reader.close();
} catch (Exception e2) {
e.printStackTrace();
}
}
return pointList;
}
public List<Point2D> convertLatLongToCoord(List<Point2D> coordinate) {
List<Point2D> latLong = new ArrayList<Point2D>();
double westMostLong = -79.974642;
double eastMostLong = -79.971244;
double longDiff = eastMostLong - westMostLong; // (rightmost_longitude -
// leftmost_longitude)
double northMostLat = 39.647556;
double southMostLat = 39.644675;
double latDiff = northMostLat - southMostLat; // (topmost_latitude -
// bottommost_latitude)
for (Point2D coord : coordinate) {
double j = coord.getY();
double k = coord.getX();
double XPixel = (((eastMostLong - j) / longDiff) * 1653);
double YPixel = (((northMostLat - k) / latDiff) * 1012);
Point2D actualCoord = new Point2D.Double(XPixel, YPixel);
latLong.add(actualCoord);
}
return latLong;
}
}
我从 GPS 传感器获得的一些 GPS 纬度/经度
输入纬度 输入经度(39.64581,-79.97168)(39.64651,-79.97275)(39.646915,-79.97342)(39.646538,-79.97279)
[IMG] http://i59.tinypic.com/nbqkk3.png[/IMG]
图中的红线是传感器获取GPS坐标时所走的路径。
但是,当我使用这个公式将纬度/经度坐标转换为像素坐标时。转换后的像素坐标不一致,如下所示:
图像 X 图像 Y(212.0977045, 613.3120444)(732.6127134, 367.4251996)(1058.542672、225.1620965)(752.0712184, 357.5897258)
X、Y(像素)坐标的变化太大。因此,当我尝试根据像素坐标移动车辆时,车辆不会遵循红线或至少接近红线。
车辆移动到红线上方或红线下方,但不能在线上。
为了使车辆基于像素坐标平滑移动,理想情况下我希望从纬度/经度到图像坐标的转换如下所示:
所需图片 X 所需图片 Y(1290, 409)(1289, 409)(1288, 409)(1287, 409)
但我明白了
图像 X 图像 Y(212.0977045, 613.3120444)(732.6127134, 367.4251996)(1058.542672、225.1620965)(752.0712184, 357.5897258)
我希望我能够传达我的问题。
最佳答案
纬度和经度不是距离。
http://geography.about.com/cs/latitudelongitude/a/latlong.htm
我最近参与了一个使用 GPS 的 Arduino 项目。我遵循 minigeo API 方法,将纬度和经度转换为北距和东距 (UTM)。
使用链接中的库可以进行此转换: http://www.ibm.com/developerworks/library/j-coordconvert/
获取最大东距和北距并计算比例
private synchronized void scale() {
int w = 800;
int h = 600;
this.scale = Math.min(
w / (maxEasting - minEasting),
h / (maxNorthing - minNorthing));
oEasting = minEasting;
oNorthing = minNorthing;
}
比转换为 X 和 Y
private int applyScale(double km) {
return (int) (km * scale);
}
private int convertX(double easting) {
return applyScale(easting - oEasting);
}
private int convertY(double northing, int height) {
return 600/*height*/ - applyScale(northing - oNorthing);
}
来源:Minigeo
关于java - 在简单的圆柱投影上将纬度/经度转换为图像坐标(像素坐标),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24874693/
我正在开发一个应用程序,用户可以在其中搜索其位置附近的项目。 当用户注册我的服务时,会获取他们的经/纬度坐标(这实际上是从邮政编码中获取的,然后通过 Google 查找经度/纬度坐标)。当用户添加一个
所以:我有以下函数,改编自在线找到的公式,它采用两个纬度/经度坐标并计算它们之间的距离(以英里为单位)(沿着球形地球): public static double distance (double l
我有一个给定点(经度、纬度),我想获取给定点 5 英里半径范围内的所有点范围? 最佳答案 我只是在这里猜测,但我认为您需要找到一种不同的方法。如果您尝试使用 Foursquare、Google map
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 5 年前。
我找到了一些代码,用于将纬度/经度转换为给定图像上的像素,反之亦然。我将其移植到 JavaScript,但在纬度上得到了不正确的返回值。我测试了原始的、未修改的代码,它给出了同样的不准确之处。下面是带
我用了AstroPy EarthLocation 获取传播卫星轨道的纬度、经度和高度 loc = coord.EarthLocation(*itrs.cartesian.xyz)。现在,我尝试使用 n
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: how to do location based search Getting similar longit
我有一个超过 15000 个经纬度坐标的列表。给定任何 X、Y 坐标,在列表中找到最近坐标的最快方法是什么? 最佳答案 您将需要使用名为 Voronoi diagram 的几何结构。 .这将平面划分为
For people interested in this topic: the accepted answer involves some concepts that I think are wel
我的应用程序上有一张 map ,它显示 2 种注释:位置和位置集群。当我放大集群时,集群会展开以显示集群中包含的位置。当这些位置添加到 map 时,其父簇的坐标将存储在注释对象中。我想要做的是制作一个
关于纬度/经度计算的简单问题。 我想获取一个值集,例如Lat: 55.123456 Long -6.123456 并计算出任意距离的四个点。 作为给定的正方形,我想计算出左侧和右侧的纬度值。因此红线距
Postgis中Linestring中的点(由osm2pgsql从osm导入)按顺序描述(经度,纬度) 例如慕尼黑 map 中的线串 'LINESTRING(11.4068032 47.8580927
给定左上长/纬度和右下长/纬度,我如何确定给定的长/纬度是否落在矩形内? 理想情况下我会看类似的东西 bool IsWithinArea(float topLeftLat,float topLeftL
几天来,我一直在尝试让纬度/经度检查器、速度计、高度计工作,但似乎没有任何工作。我尝试过使用 Android 的内置 locationmanager 和 google play 服务。现在我回来尝试
我有经纬度形式的位置坐标,例如:23⁰ 39' 24.8"N & 58⁰ 11' 36.5"E,请参见下图。但是在我的工作场所我使用 ArcGIS 并且它似乎不支持度数(纬度,经度)形式的坐标。我现在
网上看了一些教程,发现LocationManager就是这样做的。这是我在网上找到的代码。但是,我不明白。为什么我不能得到长/纬度?为什么要经历所有“改变”位置的事情...... lm=(Locati
我一直在关注此网站的教程:' http://wptrafficanalyzer.in/blog/storing-google-maps-android-api-v2-marker-locations-
我需要使用用户当前的纬度/经度和数据库中存储的一些值进行一些计算。问题是 Location.getLatitude() 返回一个类似 4119778.0 的值,而我在数据库中的值保存为 41.1675
所以在 PostgreSQL 中,我有一堆 long/lat 的几何值,其格式如下: 0101000020E610000095B9F94674CF37C09CBF0985083B5040 所以在 Po
在 GoogleMap 中,有标记的纬度和经度概念。 MySQL 中的 Point 数据类型有两个坐标 x 和 y。我不知道 Point 的坐标代表什么;所以我想知道什么表示 Point 根据 Goo
我是一名优秀的程序员,十分优秀!