UNPKG

gis-tools-ts

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

183 lines 7.61 kB
/** Area structure */ export class PJ_AREA { bbox_set; west_lon_degree; south_lat_degree; east_lon_degree; north_lat_degree; name; /** * @param bbox_set - if true, the area is defined by a bounding box * @param west_lon_degree - west longitude * @param south_lat_degree - south latitude * @param east_lon_degree - east longitude * @param north_lat_degree - north latitude * @param name - area name */ constructor(bbox_set = false, west_lon_degree = 0, // F64 south_lat_degree = 0, // F64 east_lon_degree = 0, // F64 north_lat_degree = 0, // F64 name = '') { this.bbox_set = bbox_set; this.west_lon_degree = west_lon_degree; this.south_lat_degree = south_lat_degree; this.east_lon_degree = east_lon_degree; this.north_lat_degree = north_lat_degree; this.name = name; } } /** Coordinate operation structure */ export class CoordOperation { idxInOriginalList; minxSrc; minySrc; maxxSrc; maxySrc; minxDst; minyDst; maxxDst; maxyDst; pj; name; accuracy; pseudoArea; areaName; pjSrcGeocentricToLonLat; pjDstGeocentricToLonLat; // idxInOriginalList: number; // I32 // [min|max][x|y]Src define the bounding box of the area of validity of // the transformation, expressed in the source CRS. Except if the source // CRS is a geocentric one, in which case the bounding box is defined in // a geographic lon,lat CRS (pjSrcGeocentricToLonLat will have to be used // on input coordinates in the forward direction) // minxSrc = 0; // F64 // minySrc = 0; // F64 // maxxSrc = 0; // F64 // maxySrc = 0; // F64 // [min|max][x|y]Dst define the bounding box of the area of validity of // the transformation, expressed in the target CRS. Except if the target // CRS is a geocentric one, in which case the bounding box is defined in // a geographic lon,lat CRS (pjDstGeocentricToLonLat will have to be used // on input coordinates in the inverse direction) // minxDst = 0; // F64 // minyDst = 0; // F64 // maxxDst = 0; // F64 // maxyDst = 0; // F64 isOffshore = false; isUnknownAreaName = false; isPriorityOp = false; srcIsLonLatDegree = false; srcIsLatLonDegree = false; dstIsLonLatDegree = false; dstIsLatLonDegree = false; // pjSrcGeocentricToLonLat is defined if the source CRS of pj is geocentric // and in that case it transforms from those geocentric coordinates to // geographic ones in lon, lat order // pjSrcGeocentricToLonLat?: ProjectionTransform; // pjDstGeocentricToLonLat is defined if the target CRS of pj is geocentric // and in that case it transforms from those geocentric coordinates to // geographic ones in lon, lat order // pjDstGeocentricToLonLat?: ProjectionTransform; // TODO: /** * @param idxInOriginalList - I32 * @param minxSrc - F64 * @param minySrc - F64 * @param maxxSrc - F64 * @param maxySrc - F64 * @param minxDst - F64 * @param minyDst - F64 * @param maxxDst - F64 * @param maxyDst - F64 * @param pj - ProjectionTransform * @param name - String * @param accuracy - F64 * @param pseudoArea - F64 * @param areaName - String * @param pjSrcGeocentricToLonLat - ProjectionTransform * @param pjDstGeocentricToLonLat - ProjectionTransform */ constructor(idxInOriginalList, // I32 minxSrc = 0, // F64 minySrc = 0, // F64 maxxSrc = 0, // F64 maxySrc = 0, // F64 minxDst = 0, // F64 minyDst = 0, // F64 maxxDst = 0, // F64 maxyDst = 0, // F64 pj, name = '', accuracy = -1, // F64 pseudoArea = 0, // F64 areaName = '', pjSrcGeocentricToLonLat, pjDstGeocentricToLonLat) { this.idxInOriginalList = idxInOriginalList; this.minxSrc = minxSrc; this.minySrc = minySrc; this.maxxSrc = maxxSrc; this.maxySrc = maxySrc; this.minxDst = minxDst; this.minyDst = minyDst; this.maxxDst = maxxDst; this.maxyDst = maxyDst; this.pj = pj; this.name = name; this.accuracy = accuracy; this.pseudoArea = pseudoArea; this.areaName = areaName; this.pjSrcGeocentricToLonLat = pjSrcGeocentricToLonLat; this.pjDstGeocentricToLonLat = pjDstGeocentricToLonLat; // TODO: // : idxInOriginalList(idxInOriginalListIn), minxSrc(minxSrcIn), // minySrc(minySrcIn), maxxSrc(maxxSrcIn), maxySrc(maxySrcIn), // minxDst(minxDstIn), minyDst(minyDstIn), maxxDst(maxxDstIn), // maxyDst(maxyDstIn), pj(pjIn), name(nameIn), accuracy(accuracyIn), // pseudoArea(pseudoAreaIn), areaName(areaNameIn ? areaNameIn : ""), // isOffshore(areaName.find("- offshore") != std::string::npos), // isUnknownAreaName(areaName.empty() || areaName == "unknown"), // isPriorityOp(isSpecialCaseForNAD83_to_NAD83HARN(name) || // isSpecialCaseForGDA94_to_WGS84(name) || // isSpecialCaseForWGS84_to_GDA2020(name)), // pjSrcGeocentricToLonLat(pjSrcGeocentricToLonLatIn // ? proj_clone(pjSrcGeocentricToLonLatIn->ctx, // pjSrcGeocentricToLonLatIn) // : nullptr), // pjDstGeocentricToLonLat(pjDstGeocentricToLonLatIn // ? proj_clone(pjDstGeocentricToLonLatIn->ctx, // pjDstGeocentricToLonLatIn) // : nullptr) { // const auto IsLonLatOrLatLon = [](const PJ *crs, bool &isLonLatDegreeOut, // bool &isLatLonDegreeOut) // const auto eType = proj_get_type(crs); // if (eType == PJ_TYPE_GEOGRAPHIC_2D_CRS || // eType == PJ_TYPE_GEOGRAPHIC_3D_CRS) { // const auto cs = proj_crs_get_coordinate_system(crs->ctx, crs); // const char *direction = ""; // double conv_factor = 0; // constexpr double EPS = 1e-14; // if (proj_cs_get_axis_info(crs->ctx, cs, 0, nullptr, nullptr, // &direction, &conv_factor, nullptr, // nullptr, nullptr) && // ci_equal(direction, "East")) { // isLonLatDegreeOut = fabs(conv_factor - M_PI / 180) < EPS; // } else if (proj_cs_get_axis_info(crs->ctx, cs, 1, nullptr, nullptr, // &direction, &conv_factor, nullptr, // nullptr, nullptr) && // ci_equal(direction, "East")) { // isLatLonDegreeOut = fabs(conv_factor - M_PI / 180) < EPS; // } // proj_destroy(cs); // } // }; // const auto source = proj_get_source_crs(pj->ctx, pj); // if (source) { // IsLonLatOrLatLon(source, srcIsLonLatDegree, srcIsLatLonDegree); // proj_destroy(source); // } // const auto target = proj_get_target_crs(pj->ctx, pj); // if (target) { // IsLonLatOrLatLon(target, dstIsLonLatDegree, dstIsLatLonDegree); // proj_destroy(target); // } } } //# sourceMappingURL=coords.js.map