# 关于指定的经纬度是否落在多边形内

A:

B:

C:

D:

E:

no1：

no2:

y1:

y2:

Point[] ps = new Point[] { new Point(120.2043 , 30.2795), new Point(120.2030 , 30.2511), new Point(120.1810 , 30.2543), new Point(120.1798 , 30.2781), new Point(120.1926,30.2752) };

package com.cmcc.monitor.test;

public class GisTest {

public static void main(String[] args) {
Point[] ps = new Point[] { new Point(120.2043 , 30.2795), new Point(120.2030 , 30.2511), new Point(120.1810 , 30.2543), new Point(120.1798 , 30.2781), new Point(120.1926,30.2752) };
Point n1 = new Point(120.1936 , 30.2846);
Point n2 = new Point(120.1823 , 30.2863);
Point n3 = new Point(120.2189 , 30.2712);
Point y1 = new Point(120.1902 , 30.2712);
Point y2 = new Point(120.1866 , 30.2672);
Point y4 = new Point(120.1869 , 30.2718);
System.out.println( "n1:" + isPtInPoly(n1.getX() , n1.getY() , ps));
System.out.println( "n2:" + isPtInPoly(n2.getX() , n2.getY() , ps));
System.out.println( "n3:" + isPtInPoly(n3.getX() , n3.getY() , ps));
System.out.println( "y1:" + isPtInPoly(y1.getX() , y1.getY() , ps));
System.out.println( "y2:" + isPtInPoly(y2.getX() , y2.getY() , ps));
System.out.println( "y4:" + isPtInPoly(y4.getX() , y4.getY() , ps));
}
public static boolean isPtInPoly (double ALon , double ALat , Point[] ps) {
int iSum, iCount, iIndex;
double dLon1 = 0, dLon2 = 0, dLat1 = 0, dLat2 = 0, dLon;
if (ps.length < 3) {
return false;
}
iSum = 0;
iCount = ps.length;
for (iIndex = 0; iIndex<iCount;iIndex++) {
if (iIndex == iCount - 1) {
dLon1 = ps[iIndex].getX();
dLat1 = ps[iIndex].getY();
dLon2 = ps[0].getX();
dLat2 = ps[0].getY();
} else {
dLon1 = ps[iIndex].getX();
dLat1 = ps[iIndex].getY();
dLon2 = ps[iIndex + 1].getX();
dLat2 = ps[iIndex + 1].getY();
}
// 以下语句判断A点是否在边的两端点的水平平行线之间，在则可能有交点，开始判断交点是否在左射线上
if (((ALat >= dLat1) && (ALat < dLat2)) || ((ALat >= dLat2) && (ALat < dLat1))) {
if (Math.abs(dLat1 - dLat2) > 0) {
//得到 A点向左射线与边的交点的x坐标：
dLon = dLon1 - ((dLon1 - dLon2) * (dLat1 - ALat) ) / (dLat1 - dLat2);
// 如果交点在A点左侧（说明是做射线与 边的交点），则射线与边的全部交点数加一：
if (dLon < ALon) {
iSum++;
}
}
}
}
if ((iSum % 2) != 0) {
return true;
}
return false;
}
}

package com.cmcc.monitor.test;

public class Point {
private Double x;
private Double y;
public Point (Double x , Double y) {
this.x = x;
this.y = y;
}
public Double getX() {
return x;
}
public void setX(Double x) {
this.x = x;
}
public Double getY() {
return y;
}
public void setY(Double y) {
this.y = y;
}

}

#### 在Android里如何判断一个指定的经纬度点是否落在一个多边形区域内

2016-01-25 13:10:21

#### java后台判断经纬度是否在某个区域内

2017-02-22 16:55:51

#### Java在一定范围随机生成经纬度

2016-10-27 09:46:21

#### 判断点是否在多边形区域里面

2016-08-09 15:48:17

#### 判断一个指定的经纬坐标是否落在一个多边形区域内？

2016-06-14 11:34:28

#### 判断指定的经纬度坐标点是否落在指定的多边形区域内

2012年07月23日 1KB 下载

#### 利用百度API（JavaScript 版）实现在地图上绘制任一多边形，并判断给定经纬度是否在多边形范围内。以及两点间的测距功能

2015-09-15 14:52:19

#### 地图处理方法-判断一个点是否在某个区域内

2017-11-03 12:09:20

#### java实现经纬度坐标是否在范围内的算法

2016-08-15 19:18:35

#### java-经纬度有关的计算(半径内的经纬度范围和两点间距离)

2017-04-17 18:03:36