A Vue.js project
# install dependencies
yarn
# serve with hot reload at localhost:8080
yarn dev
run the following command and navigate to localhost:8080
to view the page
Defines a single point and related operations.
Related operations include:
transform
: rotate a point against a certain centerdistanceToPointOnEarth
: physical distance to another point on earth
Defines a polygon (a series of Point
), and related operations
Related operations include:
setType
: detect type of the polygon (eitherCONVEX
orCONCAVE
), and set it internallysetOutterBound
: detect the outter bound of the polygon (外接四边形), and set it internallygetNumOfLatAcrossingPolygon
: get the number of latitudes intersecting with the polygon, and the latitude difference between each latituderotate
: rotates the polygon, basicall rotating each vertex of the polygon
Defines a vector with two points, and related operations
Related operations include:
dotProduct
: dot product with another vectorcrossProduct
: cross product with another vectorgetPointOnVectorWithY
: get the point located on this vector with a specificy
The main file for route planner, now we have three methods here:
planForConvexPolygon
: path planning for convex polygonplanForConcavePolygon
: path planning for concave polygon: first decompose the concave polygon into multiple convex polygons, and then executeplanForConvexPolygon
against each resulted convex polygonsplanForConcavePolygon2
: any other research/demo for optimal solution can go here.
Helper to draw different objects on gaode map
Detail can be viewed in class method
Some utility functions go here
CONVEX
polygon situation has been handled already, we need to implement optimal algirithm for CONCAVE
polygons
To work on it, one could start looking at planForConcavePolygon2
method in FlightRouterPlanner
Pseudo code
Rotate the polygon with `degree`
Get all intersected latitudes that are crossing the rotated polygon
Mark all lines as `unvisited`
Initialize `polylines` to be empty list (this will be the final result)
Initialize `direction` to be true
while (there is unvisited line)
line = pop the first `unvisited line` in list
`points` = the first pair of `points` that could be connected with `polylines` found on this `line`
if (the first point in this pair and the last point in `polylines` cannot be connected directly)
`points` = find path connecting first point in this pair and the last point in `polylines`
if `direction`
polylines.push(`points`)
else
polylines.push(`points` in reversed order)
`direction` = !direction (reversed direction)
mark `points` as visited
if there are `unvisited points` remaining in the `line`, move the `line ` to the end of `unvisited line` list
Rotate `polylines` back with `degree`