### Start Python HTTP Server Source: https://github.com/3liz/proj4rs/blob/main/js/README.md Use this command to start a local Python HTTP server. This is required to run the WASM examples in a browser due to security restrictions. ```bash python3 -m http.server ``` -------------------------------- ### Configure package.json for npm Publishing Source: https://github.com/3liz/proj4rs/blob/main/proj4rs/README_WASM.md Example configuration for the 'files' field in package.json to include necessary artifacts for npm publishing. ```json "files": [ "proj4rs_bg.wasm", "proj4rs_bg.wasm.d.ts", "proj4rs.js", "proj4rs_bg.js", "proj4rs.d.ts", "proj4.js" ] ``` -------------------------------- ### Basic Rust Coordinate Transformation Source: https://github.com/3liz/proj4rs/blob/main/README.md Demonstrates how to define source and target coordinate systems using proj strings and perform a point transformation in Rust. Note that the output for WGS84 is in radians and requires conversion to degrees. ```rust use proj4rs; use proj4rs::proj::Proj; // EPSG:5174 - Example let from = Proj::from_proj_string(concat!( "+proj=tmerc +lat_0=38 +lon_0=127.002890277778", " +k=1 +x_0=200000 +y_0=500000 +ellps=bessel", " +towgs84=-145.907,505.034,685.756,-1.162,2.347,1.592,6.342", " +units=m +no_defs +type=crs" )) .unwrap(); // EPSG:4326 - WGS84, known to us as basic longitude and latitude. let to = Proj::from_proj_string(concat!( "+proj=longlat +ellps=WGS84", " +datum=WGS84 +no_defs" )) .unwrap(); let mut point_3d = (198236.3200000003, 453407.8560000006, 0.0); proj4rs::transform::transform(&from, &to, &mut point_3d).unwrap(); // Note that WGS84 output from this library is in radians, not degrees. point_3d.0 = point_3d.0.to_degrees(); point_3d.1 = point_3d.1.to_degrees(); // Output in longitude, latitude, and height. println!("{} {}",point_3d.0, point_3d.1); // 126.98069676435814, 37.58308534678718 ``` -------------------------------- ### Build WASM Package for Web Source: https://github.com/3liz/proj4rs/blob/main/proj4rs/README_WASM.md Compiles the proj4rs library for the web target using wasm-pack. Use the --no-default-features flag to exclude default features. ```bash wasm-pack build --target web --no-default-features ``` -------------------------------- ### Build npm Bundle Package with Cargo-Make Source: https://github.com/3liz/proj4rs/blob/main/proj4rs/README_WASM.md Creates an npm-compatible bundle package for proj4rs using cargo-make. This is typically used for publishing to npm. ```bash cargo make wasm_bundle ``` -------------------------------- ### Build WASM Package with Cargo-Make Source: https://github.com/3liz/proj4rs/blob/main/proj4rs/README_WASM.md Builds the WASM package using the cargo-make tool. This command simplifies the build process for WASM targets. ```bash cargo make wasm ``` -------------------------------- ### Proj4js Supported Projections Source: https://github.com/3liz/proj4rs/blob/main/projections.md This list indicates projections available in the proj4js library. '+' denotes supported projections, while '-' denotes unsupported ones. ```text - [+] aea - [+] aeqd - [-] bonne - [-] cass - [+] cea - [+] eqc - [-] eqdc - [-] eqearth - [-] equi - [+] etmerc - [-] gauss - [+] geocent - [+] geos - [-] gnom - [-] gstmerc - [+] krovac - [+] laea - [+] lcc - [+] longlat - [+] merc - [+] mill - [+] moll - [-] nzmg - [-] omerc - [-] ortho - [-] poly - [-] qsc - [-] robin - [-] sinu - [+] somerc - [+] stere - [+] sterea - [+] tmerc - [-] tpers - [+] utm - [-] vandg ``` -------------------------------- ### JavaScript Coordinate Transformation with Proj4rs WASM Source: https://github.com/3liz/proj4rs/blob/main/README.md Shows how to use the JavaScript API exposed by proj4rs when compiled for WASM, mimicking the proj4js library for in-browser coordinate transformations. ```javascript let from = new Proj.Projection("+proj=latlong +ellps=GRS80"); let to = new Proj.Projection("+proj=etmerc +ellps=GRS80"); let point = new Proj.Point(2.0, 1.0, 0.0); // Point is transformed in place Proj.transform(from, to, point); ``` -------------------------------- ### Proj4rs Supported Projections Source: https://github.com/3liz/proj4rs/blob/main/projections.md This list shows projections directly defined and supported within the proj4rs library. It groups related projections together. ```text [ (latlong, longlat), (lcc), (etmerc, utm), (tmerc), (aea, leac), (stere, ups), (sterea), (merc, webmerc), (geocent, cart), (somerc), (laea), (moll, wag4, wag5), (geos), (eqc), (aeqd), (krovak), (mill), (cea), ] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.