@@ -2,14 +2,14 @@ package com.zhidaoauto.map.sdk.inner.utils
import android.util.Log
import com.zhidaoauto.map.data.point.LonLatPoint
import com.zhidaoauto.map.sdk.inner.CompileConfig
import com.zhidaoauto.map.sdk.inner.CompileConfig.DEBUG
import java.lang.Math.round
import java.math.BigDecimal
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.TimeZone
import kotlin.math.absoluteValue
import kotlin.math.*
object MathUtils {
@@ -20,20 +20,19 @@ object MathUtils {
* 大地坐标系资料WGS-84 长半径a=6378137 短半径b=6356752.3142 扁率f=1/298.2572236
*/
/** 长半径a=6378137 */
private val EARTH _R = 6378137
private val a = 6378137.0 ;
private const val EARTH _R = 6378137
private const val a = 6378137.0
/** 短半径b=6356752.3142 */
private val b = 6356752.3142 ;
private const val b = 6356752.3142
/** 扁率f=1/298.2572236 */
private val f = 1 / 298.2572236 ;
private const val f = 1 / 298.2572236
private val jl _jd = 102834.74258026089786013677476285 // 每经度单位米;
private val jl _wd = 111712.69150641055729984301412873 // 每纬度单位米;
private const val jl _jd = 102834.74258026089786013677476285 // 每经度单位米
private const val jl _wd = 111712.69150641055729984301412873 // 每纬度单位米
fun getRound ( value : Double , scale : Int ) : Double {
val bg = BigDecimal ( value )
val result : Double = bg . setScale ( scale , BigDecimal . ROUND _HALF _UP ) . toDouble ( )
return result
return bg . setScale ( scale , BigDecimal . ROUND _HALF _UP ) . toDouble ( )
}
fun getRound ( value : Double ) : Double {
@@ -50,7 +49,7 @@ object MathUtils {
val lastOfLast = list [ list . size - 2 ]
val last = list [ list . size - 1 ]
val includeAngle = getIncludeAngle ( lastOfLast , last , current )
if ( CompileConfig . DEBUG ) {
if ( DEBUG ) {
Log . i ( TAG , " getFitLonLatPoint:includeAngle: ${includeAngle} " )
}
if ( includeAngle >= 1.0 ) {
@@ -60,10 +59,10 @@ object MathUtils {
val dx = lastOfLast . longitude - last . longitude
val dy = lastOfLast . latitude - last . latitude
var u = dx * ( current . longitude - lastOfLast . longitude ) + dy * ( current . latitude - lastOfLast . latitude )
u /= Math . pow ( dx , 2.0 ) + Math . pow ( dy , 2.0 )
u /= dx . pow ( 2.0 ) + dy . pow ( 2.0 )
val targetX = lastOfLast . longitude + u * dx
val targetY = lastOfLast . latitude + u * dy
if ( CompileConfig . DEBUG ) {
if ( DEBUG ) {
Log . i ( TAG , " getFitLonLatPoint:origin: ${current.longitude} , ${current.latitude} --> ${targetX} , ${targetY} " )
}
current . longitude = targetX
@@ -80,44 +79,39 @@ object MathUtils {
val dx2 = two . longitude - zero . longitude
val dy2 = two . latitude - zero . latitude
val innerVector = dx1 * dx2 + dy1 * dy2
var radins = Math . acos ( innerVector / ( Math . sqrt ( Math . pow ( dx1 , 2.0 ) + Math . pow ( dy1 , 2.0 ) ) * Math . sqrt ( Math . pow ( dx2 , 2.0 ) + Math . pow ( dy2 , 2.0 ) ) ) )
return Math . toDegrees ( radins )
val radia ns = acos ( innerVector / ( sqrt ( dx1 . pow ( 2.0 ) + dy1 . pow ( 2.0 ) ) * sqrt ( dx2 . pow ( 2.0 ) + dy2 . pow ( 2.0 ) ) ) )
return Math . toDegrees ( radia ns )
}
/**
* UTM角度转换为经纬度对应的角度
*/
fun convertAngle ( angle : Double , lon : Double , lat : Double ) : Double {
var angleOrigin = 450 - angle
var radianOrigin = Math . toRadians ( angleOrigin . toDouble ( ) )
var radianLat = Math . toRadians ( lat )
val radianDeal = Math . atan2 ( Math . tan ( radianOrigin ) * Math . cos ( radianLat ) , 1.0 )
var ruler = 270
if ( angle >= 0 && angle < 180 ) {
ruler = 90
val angleOrigin = 450 - angle
val radianOrigin = Math . toRadians ( angleOrigin )
val radianLat = Math . toRadians ( lat )
val radianDeal = atan2 ( tan ( radianOrigin ) * cos ( radianLat ) , 1.0 )
val ruler : Int = if ( angle >= 0 && angle < 180 ) {
90
} else {
ruler = 270
270
}
val result = ruler - Math . toDegrees ( radianDeal )
return result
return ruler - Math . toDegrees ( radianDeal )
}
/**
* 角度转换为经纬度对应的角度
*/
fun convertFlatAngle ( angle : Double , lon : Double , lat : Double ) : Double {
var angle Origin = angle
var radianOrigin = Math . toRadians ( angleOrigin . toDouble ( ) )
var radianLat = Math . toRadians ( lat )
val radianDeal = Math . atan2 ( Math . tan ( radianOrigin ) * Math . cos ( radianLat ) , 1. 0 )
var ruler = 27 0
if ( angle >= 0 && angle < 180 ) {
ruler = 90
val radian Origin = Math . toRadians ( angle )
val radianLat = Math . toRadians ( lat )
val radianDeal = atan2 ( tan ( radianOrigin ) * cos ( radianLat ) , 1.0 )
val ruler = if ( angle >= 0 && angle < 18 0 ) {
9 0
} else {
ruler = 270
270
}
val result = ruler - Math . toDegrees ( radianDeal )
return result
return ruler - Math . toDegrees ( radianDeal )
}
@@ -164,15 +158,15 @@ object MathUtils {
return distance ( front . longitude , front . latitude , end . longitude , end . latitude )
}
fun getDistance ( lon1 : Double , lat1 : Double , lon2 : Double , lat2 : Double ) : Double {
var radLat1 = Math . toRadians ( lat1 ) ;
var radLat2 = Math . toRadians ( lat2 ) ;
var a = radLat1 - radLat2 ;
var b = Math . toRadians ( lon1 ) - Math . toRadians ( lon2 ) ;
var s = 2 * Math . asin ( Math . sqrt ( Math . pow ( Math . sin ( a / 2 ) , 2.0 ) + Math . cos ( radLat1 ) * Math . cos ( radLat2 ) * Math . pow ( Math . sin ( b / 2 ) , 2.0 ) ) ) ;
s = s * EARTH _R ;
s = Math . round ( s * 10000 ) / 10000.0 ;
return s ;
fun getDistance ( lon1 : Double , lat1 : Double , lon2 : Double , lat2 : Double ) : Double {
val radLat1 = Math . toRadians ( lat1 )
val radLat2 = Math . toRadians ( lat2 )
val a = radLat1 - radLat2
val b = Math . toRadians ( lon1 ) - Math . toRadians ( lon2 )
var s = 2 * asin ( sqrt ( sin ( a / 2 ) . pow ( 2.0 ) + cos ( radLat1 ) * cos ( radLat2 ) * sin ( b / 2 ) . pow ( 2.0 ) ) )
s *= EARTH _R
s = round ( s * 10000 ) / 10000.0
return s
}
@@ -181,10 +175,10 @@ object MathUtils {
if ( distance == 0f ) {
return null
}
val radian = Math . toRadians ( angle . toDouble ( ) )
val radianCoa ngle = Math . toRadians ( 90.0 - angle . toDouble ( ) )
var nLon = lon + distance * Math . sin ( radian ) / 100000.0
var nLat = lat + distance * Math . sin ( radianCoa ngle ) / 100000.0
val radian = Math . toRadians ( angle )
val radianCoA ngle = Math . toRadians ( 90.0 - angle )
val nLon = lon + distance * sin ( radian ) / 100000.0
val nLat = lat + distance * sin ( radianCoA ngle ) / 100000.0
return LonLatPoint ( nLon , nLat , 0.0 , angle )
}
@@ -209,14 +203,13 @@ object MathUtils {
* @param @return 参数
* @return String 平移后的经纬度 返回类型
*/
fun right ( lon : Double , lat : Double , dist : Double ) : String ? {
fun right ( lon : Double , lat : Double , dist : Double ) : String {
val d : Double = dist / a
val cs = Math . cos ( rad ( lat ) )
val cs = cos ( rad ( lat ) )
val c = d / cs * 180.0 / Math . PI
return ( lon + c ) . toString ( ) + " , " + lat
}
/**
*
* @Title: top
@@ -227,7 +220,7 @@ object MathUtils {
* @param @return 参数
* @return String 平移后的经纬度 返回类型
*/
fun top ( lon : Double , lat : Double , dist : Double ) : String ? {
fun top ( lon : Double , lat : Double , dist : Double ) : String {
val d : Double = dist / a
val c = d / Math . PI * 180.0
return lon . toString ( ) + " , " + ( lat + c )
@@ -239,32 +232,32 @@ object MathUtils {
fun getAngle ( pLine : ArrayList < LonLatPoint > ) : Float {
var tempAngle = 0.0
if ( pLine . size == 1 ) {
tempAngle = pLine . get ( 0 ) . angle
tempAngle = pLine [ 0 ] . angle
} else {
var lonLatPoint = pLine . get ( pLine . size - 1 )
var lastl onLatPoint : LonLatPoint ? = null
pLine ? .let {
val lonLatPoint = pLine [ pLine . size - 1 ]
var lastL onLatPoint : LonLatPoint ?
pLine .let {
if ( it . size < 5 ) {
lastl onLatPoint = pLine . get ( 0 ) ;
lastL onLatPoint = pLine [ 0 ]
} else {
lastl onLatPoint = pLine . get ( 3 ) ;
var dis = distance ( lonLatPoint . longitude , lonLatPoint . latitude , lastl onLatPoint !! . longitude , lastl onLatPoint !! . latitude )
lastL onLatPoint = pLine [ 3 ]
val dis = distance ( lonLatPoint . longitude , lonLatPoint . latitude , lastL onLatPoint !! . longitude , lastL onLatPoint !! . latitude )
if ( dis < 0.2 ) {
lastlonLatPoint = pLine . get ( 0 )
lastLonLatPoint = if ( dis < 0.2 ) {
pLine [ 0 ]
} else if ( dis < 0.8 ) {
lastlonLatPoint = pLine . get ( 1 )
pLine [ 1 ]
} else if ( dis < 1.2 ) {
lastlonLatPoint = pLine . get ( 2 )
pLine [ 2 ]
} else {
lastlonLatPoint = pLine . get ( 3 )
pLine [ 3 ]
}
}
}
if ( lonLatPoint != null && lastl onLatPoint != null ) {
if ( lonLatPoint != null && lastL onLatPoint != null ) {
tempAngle = GisGeomTool . getAngleToNorth (
getRound ( lonLatPoint . longitude ) - getRound ( lastl onLatPoint !! . longitude ) ,
getRound ( lonLatPoint . latitude ) - getRound ( lastl onLatPoint !! . latitude )
getRound ( lonLatPoint . longitude ) - getRound ( lastL onLatPoint !! . longitude ) ,
getRound ( lonLatPoint . latitude ) - getRound ( lastL onLatPoint !! . latitude )
)
}
@@ -273,7 +266,7 @@ object MathUtils {
}
}
if ( DEBUG ) {
Log . i ( TAG , " angleop--tempAngle: ${ tempAngle} " )
Log . i ( TAG , " angleop--tempAngle: $tempAngle " )
}
return tempAngle . toFloat ( )
@@ -287,75 +280,68 @@ object MathUtils {
var index = 0
var diffValOrigin = 0.0f
var diffValCal = 0.0f
var lonLatPoint = pLine . get ( pLine . size - 1 )
val lonLatPoint = pLine [ pLine . size - 1 ]
if ( pLine . size == 1 ) {
tempAngle = lonLatPoint . angle
} else {
var lastl onLatPoint : LonLatPoint ? = null
lastlonLatPoint = pL ine . get ( pL ine . size - 2 ) ;
var dis = distance ( lonLatPoint . longitude , lonLatPoint . latitude , lastlonLatPoint !! . longitude , lastlonLatPoint !! . latitude )
var lastL onLatPoint : LonLatPoint = pLine [ pLine . size - 2 ]
val dis = distance ( lonLatPoint . longitude , lonLatPo int . latitude , lastLonLatPo int . longitude , lastLonLatPoint . latitude )
if ( dis < 0.2 ) {
index = 0
index = if ( dis < 0.2 ) {
0
} else if ( dis < 0.8 ) {
index = 1
1
} else if ( dis < 1.2 ) {
index = 2
2
} else {
index = 3
3
}
if ( index >= pLine . size ) {
index = pLine . size - 2
}
lastl onLatPoint = pLine . get ( index )
if ( lonLatPoint != null && lastlonLatPoint != null ) {
tempAngle = GisGeomTool . getAngleToNorth (
getRound ( lonLatPoint . long itude ) - getRound ( lastl onLatPoint !! . long itude ) ,
getRound ( lonLatPoint . latitude ) - getRound ( lastlonLatPoint !! . latitude )
)
}
lastL onLatPoint = pLine [ index ]
tempAngle = GisGeomTool . getAngleToNorth (
getRound ( lonLatPoint . longitude ) - getRound ( lastLonLatPoint . longitude ) ,
getRound ( lonLatPoint . lat itude ) - getRound ( lastL onLatPoint . lat itude )
)
if ( tempAngle == - 400.0 ) {
if ( angles != null && angles . size > 0 ) {
tempAngle = angles . get ( angles . size - 1 )
tempAngle = if ( angles != null && angles . size > 0 ) {
angles [ angles . size - 1 ]
} else {
tempAngle = lonLatPoint. angle
lonLatPoint . angle
}
}
var midAngle = tempAngle
}
return tempAngle . toFloat ( )
}
fun getLocationAngle ( pLine : ArrayList < LonLatPoint > ) : Float {
var tempAngle = 0.0
val MAX _DISTANCE = 6
var index = 0
var lonLatPoint = pLine . get ( pLine . size - 1 )
val lonLatPoint = pLine [ pLine . size - 1 ]
if ( pLine . size == 1 ) {
tempAngle = lonLatPoint . angle
} else {
var lastl onLatPoint : LonLatPoint ? = null
var lastL onLatPoint : LonLatPoint ? = null
var dis = 0.0
for ( i in 1 .. pLine . size - 1 ) {
lastl onLatPoint = pLine . get ( pLine . size - 1 - i )
lastl onLatPoint ? .let {
lastL onLatPoint = pLine [ pLine . size - 1 - i ]
lastL onLatPoint .let {
dis = distance ( lonLatPoint . longitude , lonLatPoint . latitude , it . longitude , it . latitude )
index = pLine . size - 1 - i
Log . d ( TAG , " angleooo--distance: ${dis} , index: ${ index} " )
Log . d ( TAG , " angleooo--distance: ${dis} , index: $index " )
}
if ( dis >= MAX _DISTANCE ) {
break
}
}
if ( lonLatPoint != null && lastl onLatPoint != null ) {
if ( lonLatPoint != null && lastL onLatPoint != null ) {
tempAngle = GisGeomTool . getAngleToNorth (
lonLatPoint . longitude - lastl onLatPoint !! . longitude ,
lonLatPoint . latitude - lastl onLatPoint !! . latitude
lonLatPoint . longitude - lastL onLatPoint . longitude ,
lonLatPoint . latitude - lastL onLatPoint . latitude
)
}
@@ -364,11 +350,11 @@ object MathUtils {
}
if ( DEBUG ) {
Log . d ( TAG , " angleooo-lastlonLatPoint: ${lastl onLatPoint} , distance:${dis} ,index: ${index} , tempAngle: ${tempAngle} " )
Log . d ( TAG , " angleooo-lastlonLatPoint: ${lastL onLatPoint} , distance:${dis} ,index: ${index} , tempAngle: ${tempAngle} " )
}
if ( DEBUG ) {
for ( lonl at in pLine ) {
Log . d ( TAG , " angleooo-lonlat: ${ lonl at} " )
for ( lonL at in pLine ) {
Log . d ( TAG , " angleooo-lonlat: $lonL at " )
}
}
@@ -379,9 +365,9 @@ object MathUtils {
fun utcToUnix ( time : Long ) : Long {
val calendar = Calendar . getInstance ( TimeZone . getTimeZone ( " UTC " ) )
calendar . timeInMillis = time
val localFormater = DateFormat . getInstance ( ) ; //当地时间格式
localFormater . setT imeZone( TimeZone . getDefault ( ) ) ;
val localTime = localFormater . format ( calendar . getTime ( ) ) ;
val localFormatt er = DateFormat . getInstance ( ) //当地时间格式
localFormatt er . t imeZone = TimeZone . getDefault ( )
val localTime = localFormatt er . format ( calendar . time )
return SimpleDateFormat ( ) . parse ( localTime ) . time
}
@@ -389,7 +375,7 @@ object MathUtils {
if ( DEBUG ) {
Log . i ( TAG , " getSmoothPoints: 平滑原始数据: ${line.size} " )
}
var list : ArrayList < LonLatPoint > = ArrayList < LonLatPoint > ()
val list : ArrayList < LonLatPoint > = ArrayList ( )
if ( line . size < 11 ) {
return line
}
@@ -421,9 +407,9 @@ object MathUtils {
for ( j in numBefore until i ) {
sumY += line [ j ] . latitude
}
var num = numAfter - numBefore
var x = sumX / num
var y = sumY / num
val num = numAfter - numBefore
val x = sumX / num
val y = sumY / num
val lonlatPoint = LonLatPoint ( x , y )
list . add ( lonlatPoint )
}
@@ -437,18 +423,18 @@ object MathUtils {
if ( DEBUG ) {
Log . i ( TAG , " getPoints: 插值原始数据: ${line.size} " )
}
var lonLatPoints : ArrayList < LonLatPoint > = ArrayList < LonLatPoint > ()
if ( line != null && line . size > 0 ) {
val lonLatPoints : ArrayList < LonLatPoint > = ArrayList ( )
if ( line . size > 0 ) {
var startLonLatPoint = line [ 0 ]
for ( i in 0 until line . size - 1 ) {
var start = startLonLatPoint
var end = line [ i + 1 ]
val start = startLonLatPoint
val end = line [ i + 1 ]
if ( i == 0 ) {
lonLatPoints . add ( start )
}
val x = end . latitude - start . latitude
val y = end . longitude - start . longitude
val dis = Math . sqrt ( x * x + y * y ) . absoluteValue * 100000
val dis = sqrt ( x * x + y * y ) . absoluteValue * 100000
val unit = dis / factor
val num = unit . toInt ( )
if ( num <= 0 ) {
@@ -460,11 +446,11 @@ object MathUtils {
for ( i in 1. . num ) {
val lon = start . longitude + numY * i
val lat = start . latitude + numX * i
val lonl atPoint = LonLatPoint ( lon , lat )
val lonL atPoint = LonLatPoint ( lon , lat )
if ( i == num ) {
startLonLatPoint = lonl atPoint
startLonLatPoint = lonL atPoint
}
lonLatPoints . add ( lonl atPoint )
lonLatPoints . add ( lonL atPoint )
}
}
@@ -478,14 +464,14 @@ object MathUtils {
fun getTravelList ( travel : String ) : ArrayList < LonLatPoint > {
var list = ArrayList < LonLatPoint > ( )
val list = ArrayList < LonLatPoint > ( )
var mTravel = travel . trim ( )
if ( mTravel . isNotEmpty ( ) ) {
if ( mTravel . endsWith ( " , " ) ) {
mTravel = mTravel . trim ( ',' )
}
var array = mTravel . split ( " , " )
val array = mTravel . split ( " , " )
if ( array != null && array . size >= 2 && array . size % 2 == 0 ) {
for ( i in 0. . array . size - 1 step 2 ) {
val lonLatPoint = LonLatPoint ( array [ i ] . toDouble ( ) , array [ i + 1 ] . toDouble ( ) )
@@ -533,25 +519,25 @@ object MathUtils {
*/
fun destination ( lng : Double , lat : Double , heading : Double , distance : Double ) : DoubleArray {
//计算扇形的眯点坐标
val h ead ing = ( heading + 360 ) % 360
val b ear ing = ( heading + 360 ) % 360
val rad = Math . PI / 180
val radInv = 180 / Math . PI
var lonRad = lng * rad
var latRad = lat * rad
var rh eading = h ead ing * rad
var sinLatRad = Math . sin ( latRad )
var cosLatRad = Math . cos ( latRad )
var cosDistR = Math . cos ( distance / EARTH _R )
var sinDistR = Math . sin ( distance / EARTH _R )
var lat2 = Math . asin (
sinLatRad * cosDistR + cosLatRad * sinDistR * Math . cos ( rh eading )
val lonRad = lng * rad
val latRad = lat * rad
val rH eading = b ear ing * rad
val sinLatRad = sin ( latRad )
val cosLatRad = cos ( latRad )
val cosDistR = cos ( distance / EARTH _R )
val sinDistR = sin ( distance / EARTH _R )
var lat2 = asin (
sinLatRad * cosDistR + cosLatRad * sinDistR * cos ( rH eading )
)
var lon2 = lonRad +
Math . atan2 (
Math . sin ( rh eading ) * sinDistR * cosLatRad ,
cosDistR - sinLatRad * Math . sin ( lat2 )
) ;
lon2 = lon2 * radInv;
atan2 (
sin ( rH eading ) * sinDistR * cosLatRad ,
cosDistR - sinLatRad * sin ( lat2 )
)
lon2 * = radInv
lon2 = if ( lon2 > 180 ) {
lon2 - 360
} else {
@@ -561,7 +547,7 @@ object MathUtils {
lon2
}
}
lat2 = lat2 * radInv
lat2 *= radInv
return doubleArrayOf ( lon2 , lat2 )
}
@@ -668,20 +654,19 @@ object MathUtils {
}
// 计算两个线段的夹角
fun computeAngle ( segment1 : Pair < LonLatPoint , LonLatPoint > , segment2 : Pair < LonLatPoint , LonLatPoint > ) : Double ? {
fun computeAngle ( segment1 : Pair < LonLatPoint , LonLatPoint > , segment2 : Pair < LonLatPoint , LonLatPoint > ) : Double {
// 计算线段1的方向向量
val v1 = LonLatPoint ( segment1 . second . longitude - segment1 . first . longitude , segment1 . second . latitude - segment1 . first . latitude )
// 计算线段2的方向向量
val v2 = LonLatPoint ( segment2 . second . longitude - segment2 . first . longitude , segment2 . second . latitude - segment2 . first . latitude )
// 计算向量夹角的余弦值
val cosAngle = ( v1 . longitude * v2 . longitude + v1 . latitude * v2 . latitude ) / ( Math . sqrt ( v1 . longitude * v1 . longitude + v1 . latitude * v1 . latitude ) * Math . sqrt ( v2 . longitude * v2 . longitude + v2 . latitude * v2 . latitude ) )
val cosAngle = ( v1 . longitude * v2 . longitude + v1 . latitude * v2 . latitude ) / ( sqrt ( v1 . longitude * v1 . longitude + v1 . latitude * v1 . latitude ) * sqrt ( v2 . longitude * v2 . longitude + v2 . latitude * v2 . latitude ) )
// 返回角度值
return Math . toDegrees ( Math . acos ( cosAngle ) )
return Math . toDegrees ( acos ( cosAngle ) )
}
// 获取距离自车最近的点及其下标
fun getNearestPoints ( mLonl atPoint : LonLatPoint , pointList : MutableList < LonLatPoint > ) : MutableList < LonLatPoint > ? {
fun getNearestPoints ( mLonL atPoint : LonLatPoint , pointList : MutableList < LonLatPoint > ) : MutableList < LonLatPoint > ? {
if ( pointList . isEmpty ( ) ) {
return null
}
@@ -689,7 +674,7 @@ object MathUtils {
var nearestIndex = - 1
for ( ( index , point ) in pointList . withIndex ( ) ) {
val distance = distance ( mLonl atPoint , point )
val distance = distance ( mLonL atPoint , point )
if ( distance < minDistance ) {
minDistance = distance
nearestIndex = index
@@ -700,21 +685,18 @@ object MathUtils {
}
fun isInRegion ( lon : Double , lat : Double , list : List < List < Double > > ? ) : Boolean {
var iSum : Int
val iCount : Int
var iIndex : Int
var dLon1 = 0.0
var dLon2 = 0.0
var dLat1 = 0.0
var dLat2 = 0.0
var dLon1 : Double
var dLon2 : Double
var dLat1 : Double
var dLat2 : Double
var dLon : Double
list ?: return false
if ( list . size < 3 ) {
return false
}
iSum = 0
iCount = list . size
iIndex = 0
var iSum = 0
val iCount = list . size
var iIndex = 0
while ( iIndex < iCount ) {
if ( iIndex == iCount - 1 ) {
dLon1 = list [ iIndex ] [ 0 ]
@@ -729,7 +711,7 @@ object MathUtils {
}
// 以下语句判断A点是否在边的两端点的水平平行线之间, 在则可能有交点, 开始判断交点是否在左射线上
if ( lat >= dLat1 && lat < dLat2 || lat >= dLat2 && lat < dLat1 ) {
if ( Math . abs ( dLat1 - dLat2 ) > 0 ) {
if ( abs ( dLat1 - dLat2 ) > 0 ) {
//得到 A点向左射线与边的交点的x坐标:
dLon = dLon1 - ( dLon1 - dLon2 ) * ( dLat1 - lat ) / ( dLat1 - dLat2 )
// 如果交点在A点左侧( 说明是做射线与 边的交点),则射线与边的全部交点数加一: