diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java index 33009b27b..7507185f8 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java @@ -8,6 +8,7 @@ import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; +import com.fangjia.open.util.InsidePolygon2; import com.fangjia.service.mongo.fangjia.PriceBorderService; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -808,10 +809,13 @@ public class WeiXinEvaluationController { Point point = new Point(Double.valueOf(ll[0]), Double.valueOf(ll[1])); points.add(point); } - Point point = new Point(district.getLng2()/10000000000.0, district.getLat2()/10000000000.0); - boolean flag = InsidePolygon.aboutZone(point, points); + Point point = new Point(district.getLng()/10000000000.0, district.getLat()/10000000000.0); + //boolean flag = InsidePolygon.aboutZone(point, points); + //boolean flag = InsidePolygon.isPtInPoly(point.getLon(), point.getLat(), points); + boolean flag = InsidePolygon2.checkIsInPolygon(point, points); if(flag){ pbObj = pb; + System.out.println(district.getRegion()+" "+district.getName()+" "+pb.getName()); break; } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/InsidePolygon.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/InsidePolygon.java index 096e1ae99..55706d5b4 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/util/InsidePolygon.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/InsidePolygon.java @@ -143,5 +143,44 @@ public class InsidePolygon { if ( ( (odd >> 1) << 1) == odd) return false; return true; - } + } + + + public static boolean isPtInPoly (double ALon , double ALat , List ps) { + int iSum, iCount, iIndex; + double dLon1 = 0, dLon2 = 0, dLat1 = 0, dLat2 = 0, dLon; + if (ps.size() < 3) { + return false; + } + iSum = 0; + iCount = ps.size(); + for (iIndex = 0; iIndex= 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; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/InsidePolygon2.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/InsidePolygon2.java new file mode 100644 index 000000000..2ecdb60fe --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/InsidePolygon2.java @@ -0,0 +1,116 @@ +package com.fangjia.open.util; + +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +public class InsidePolygon2 { + /** + * 判断当前位置是否在多边形区域内 + * + * @param checkPoint 当前经纬度 + * @param areaAround 围栏范围 + * @return + */ + public static boolean checkIsInPolygon(Point checkPoint, List areaAround) { + Point2D.Double point = new Point2D.Double(checkPoint.getLat(), checkPoint.getLon()); + List pointList = new ArrayList(); + for (Point everyPoint : areaAround) { + Point2D.Double polygonPoint = new Point2D.Double(everyPoint.getLat(), everyPoint.getLon()); + pointList.add(polygonPoint); + } + return checkIsPtInPoly(point, pointList); + } + + /** + * 判断点是否在多边形内,如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true + * + * @param point 检测点 + * @param pts 多边形的顶点 + * @return 点在多边形内返回true, 否则返回false + */ + public static boolean checkIsPtInPoly(Point2D.Double point, List pts) { + int N = pts.size(); + //如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true + boolean boundOrVertex = true; + //cross points count of x + int intersectCount = 0; + //浮点类型计算时候与0比较时候的容差 + double precision = 2e-10; + //neighbour bound vertices + Point2D.Double p1, p2; + //当前点 + Point2D.Double p = point; + //left vertex + p1 = pts.get(0); + //check all rays + for (int i = 1; i <= N; ++i) { + if (p.equals(p1)) { + //p is an vertex + return boundOrVertex; + } + //right vertex + p2 = pts.get(i % N); + //ray is outside of our interests + if (p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)) { + p1 = p2; + //next ray left point + continue; + } + //ray is crossing over by the algorithm (common part of) + if (p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)) { + //x is before of ray + if (p.y <= Math.max(p1.y, p2.y)) { + //overlies on a horizontal ray + if (p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)) { + return boundOrVertex; + } + //ray is vertical + if (p1.y == p2.y) { + //overlies on a vertical ray + if (p1.y == p.y) { + return boundOrVertex; + //before ray + } else { + ++intersectCount; + } + } else { + //cross point on the left side + //cross point of y + double xinters = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y; + //overlies on a ray + if (Math.abs(p.y - xinters) < precision) { + return boundOrVertex; + } + //before ray + if (p.y < xinters) { + ++intersectCount; + } + } + } + } else { + //special case when ray is crossing through the vertex + //p crossing over p2 + if (p.x == p2.x && p.y <= p2.y) { + //next vertex + Point2D.Double p3 = pts.get((i + 1) % N); + //p.x lies between p1.x & p3.x + if (p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)) { + ++intersectCount; + } else { + intersectCount += 2; + } + } + } + //next ray left point + p1 = p2; + } + //偶数在多边形外 + if (intersectCount % 2 == 0) { + return false; + } else { + //奇数在多边形内 + return true; + } + } +} diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh1.png b/projects/fangjia-open/src/main/webapp/static/images/bh1.png new file mode 100644 index 000000000..7244082f7 Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh1.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh10.png b/projects/fangjia-open/src/main/webapp/static/images/bh10.png new file mode 100644 index 000000000..28b44cc90 Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh10.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh2.png b/projects/fangjia-open/src/main/webapp/static/images/bh2.png new file mode 100644 index 000000000..4d817b65c Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh2.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh3.png b/projects/fangjia-open/src/main/webapp/static/images/bh3.png new file mode 100644 index 000000000..ed5e5c842 Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh3.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh4.png b/projects/fangjia-open/src/main/webapp/static/images/bh4.png new file mode 100644 index 000000000..0e0baf659 Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh4.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh5.png b/projects/fangjia-open/src/main/webapp/static/images/bh5.png new file mode 100644 index 000000000..6ebc1f6aa Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh5.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh6.png b/projects/fangjia-open/src/main/webapp/static/images/bh6.png new file mode 100644 index 000000000..ed5e5c842 Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh6.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh7.png b/projects/fangjia-open/src/main/webapp/static/images/bh7.png new file mode 100644 index 000000000..6c8c78701 Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh7.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh8.png b/projects/fangjia-open/src/main/webapp/static/images/bh8.png new file mode 100644 index 000000000..2c2be1821 Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh8.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bh9.png b/projects/fangjia-open/src/main/webapp/static/images/bh9.png new file mode 100644 index 000000000..3bc4e5db5 Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bh9.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bhbj.png b/projects/fangjia-open/src/main/webapp/static/images/bhbj.png new file mode 100644 index 000000000..6fa3694bd Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bhbj.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bhbm.png b/projects/fangjia-open/src/main/webapp/static/images/bhbm.png new file mode 100644 index 000000000..4c8bed8e7 Binary files /dev/null and b/projects/fangjia-open/src/main/webapp/static/images/bhbm.png differ diff --git a/projects/fangjia-open/src/main/webapp/static/images/bohaiyidai2.jpg b/projects/fangjia-open/src/main/webapp/static/images/bohaiyidai2.jpg index 7d6910f1e..747858edd 100644 Binary files a/projects/fangjia-open/src/main/webapp/static/images/bohaiyidai2.jpg and b/projects/fangjia-open/src/main/webapp/static/images/bohaiyidai2.jpg differ diff --git a/projects/fangjia-open/src/main/webapp/user/bhydLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/bhydLoginPage.ftl index f319e34e9..2d7980a81 100644 --- a/projects/fangjia-open/src/main/webapp/user/bhydLoginPage.ftl +++ b/projects/fangjia-open/src/main/webapp/user/bhydLoginPage.ftl @@ -21,8 +21,9 @@
- @@ -51,7 +53,28 @@