Module: PolygonSplitter

Splits polygons that cross the anti-meridian and/or contain a pole.
Source:

Methods

(static) createPoint(latitude, longitude, altitude)

Internal. Applications should not call this method. Creates a Location or a Position
Parameters:
Name Type Description
latitude Number
longitude Number
altitude Number
Source:
Returns:
Location | Position

(static) determinePole(minLatitude, maxLatitude) → {Number}

Internal. Applications should not call this method. Determine which pole is enclosed. If the shape is entirely in one hemisphere, then assume that it encloses the pole in that hemisphere. Otherwise, assume that it encloses the pole that is closest to the shape's extreme latitude.
Parameters:
Name Type Description
minLatitude Number The minimum latitude of a polygon that contains a pole
maxLatitude Number The maximum latitude of a polygon that contains a pole
Source:
Returns:
The pole number @see Location.poles
Type
Number

(static) findIntersectionAndPole(points, newPoints, intersections, iMap) → {Number}

Internal. Applications should not call this method. Finds the intersections with the anti-meridian and if the polygon contains one of the poles. A new polygon is constructed with the intersections and pole points and stored in newPoints
Parameters:
Name Type Description
points Array.<Location> | Array.<Position> An array of Locations or Positions that define a polygon
newPoints Array.<Location> | Array.<Position> An empty array where to store the resulting polygon with intersections
intersections Array An empty array where to store the intersection latitude and index
iMap HashMap A hashMap to store intersection data The key is the index in the newPoints array and value is PolygonSplitter.makeIntersectionEntry
Source:
Returns:
The pole number @see Location.poles
Type
Number

(static) formatContourOutput(polygons, pole, poleIndex, iMaps)

Internal. Applications should not call this method.
Parameters:
Name Type Description
polygons Array an array of arrays of Locations or Positions
pole Number the pole number @see Location.poles
poleIndex Number the index of the polygon containing the pole
iMaps Array.<HashMap> an array of hash maps for each polygon
Source:

(static) handleOnePole(points, intersections, iMap, pole) → {Object}

Internal. Applications should not call this method. Creates a new array of points containing the two pole locations on both sides of the anti-meridian
Parameters:
Name Type Description
points Array.<Location> | Array.<Position>
intersections Array
iMap HashMap
pole Number
Source:
Returns:
an object containing the new points and a new reIndexed iMap
Type
Object

(static) linkIntersections(intersections, iMap)

Internal. Applications should not call this method. Links adjacents pairs of intersection by index
Parameters:
Name Type Description
intersections Array
iMap HashMap
Source:

(static) makeIntersectionEntry(index)

Internal. Applications should not call this method.
Parameters:
Name Type Description
index Number the index of the intersection in the array of points
Source:

(static) makePolygon(start, end, points, iMap, resultPolygon, polygonHashMap) → {Boolean}

Internal. Applications should not call this method. Paths from a start intersection index to an end intersection index and makes a polygon and a hashMap with the intersection indices
Parameters:
Name Type Description
start Number the index of a start type intersection
end Number the index of an end type intersection
points Array.<Location> | Array.<Position>
iMap HashMap
resultPolygon Array.<Location> | Array.<Position> an empty array to store the resulting polygon
polygonHashMap HashMap a hash map to record the indices of the intersections in the polygon
Source:
Returns:
true if the polygon contains a pole
Type
Boolean

(static) makePolygons(points, intersections, iMap, polygons, iMaps) → {Number}

Internal. Applications should not call this method.
Parameters:
Name Type Description
points Array.<Location> | Array.<Position>
intersections Array
iMap HashMap
polygons Array an empty array to store the resulting polygons
iMaps Array.<HashMap> an empty array to store the resulting hasp maps for each polygon
Source:
Returns:
the pole number @see Location.poles
Type
Number

(static) reindexIntersections(intersections, iMap, indexOffset) → {HashMap}

Internal. Applications should not call this method. ReIndexes the intersections due to the poles being added to the array of points
Parameters:
Name Type Description
intersections Array
iMap HashMap
indexOffset Number the index from which to start reIndexing
Source:
Returns:
a new hash map with the correct indices
Type
HashMap

(static) safeAdd(points, point, index, len)

Internal. Applications should not call this method. Adds an element to an array preventing duplication
Parameters:
Name Type Description
points Array.<Location> | Array.<Position>
point Location | Position
index Number The index of the Point from the source array
len Number The length of the source array
Source:

(static) splitContour(points) → {Object}

Splits a polygon that cross the anti-meridian or contain a pole.
Parameters:
Name Type Description
points Array.<Location> | Array.<Position> an array of Locations or Positions that define a polygon
Source:
Returns:
@see PolygonSplitter.formatContourOutput
Type
Object

(static) splitContours(contours, resultContours) → {Boolean}

Splits an array of polygons that cross the anti-meridian or contain a pole.
Parameters:
Name Type Description
contours Array an array of arrays of Locations or Positions Each array entry defines one of this polygon's boundaries.
resultContours Array an empty array to put the result of the split. Each element will have the shape of PolygonSplitter.formatContourOutput
Source:
Returns:
true if one of the boundaries crosses the anti-meridian otherwise false
Type
Boolean