Calculate Geodesic Intersection

node v6.17.1
version: 1.0.0
endpointsharetweet
let Cesium = require("cesium") let geodesy = require("geodesy") // Convert Cesium.Cartographic to geodesy.LatLonVectors class function toLatLon(point) { return new geodesy.LatLonVectors( Cesium.Math.toDegrees(point.latitude), Cesium.Math.toDegrees(point.longitude)); } // Create one geodesic const start1 = new Cesium.Cartographic(-80, 45); const end1 = new Cesium.Cartographic(-85, 45); const geod1 = new Cesium.EllipsoidGeodesic(start1, end1); // Create second geodesic const start2 = new Cesium.Cartographic(-83, 40); const end2 = new Cesium.Cartographic(-83, 49); const geod2 = new Cesium.EllipsoidGeodesic(start2, end2); /** * Get the bearing of the geodesic from the start point * Yes, you could probably use EllipsoidGeodesic.startHeading * I just prefer to use one library for all the calculations in case there is a difference in math */ const start1Vector = toLatLon(start1); // Create start1 geodesy.LatLonVectors const end1Vector = toLatLon(end1) // Create end1 geodesy.LatLonVectors const geod1Bearing = start1Vector.bearingTo(end1Vector); // Get bearing // Do the same for the second geodesic const start2Vector = toLatLon(start2); const end2Vector = toLatLon(end2) const geod2Bearing = start1Vector.bearingTo(end2Vector); // Caluclate the intersection const geoIntersect = geodesy.LatLonVectors.intersection( start1Vector, geod1Bearing, start2Vector, geod2Bearing);
Loading…

no comments

    sign in to comment