Skip to content

Commit

Permalink
extract proj4 config into local module
Browse files Browse the repository at this point in the history
  • Loading branch information
twelch committed Dec 22, 2023
1 parent 615d2c4 commit f5cb2d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 1 addition & 9 deletions packages/geoprocessing/src/toolbox/geoblaze/geoblaze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Polygon, Histogram } from "../../types";
import { Feature, MultiPolygon, FeatureCollection, BBox } from "@turf/helpers";
import geoblaze, { Georaster } from "geoblaze";
import reprojectGeoJSONPlugable from "reproject-geojson/pluggable.js";
import proj4 from "proj4";
import proj4 from "../proj4";
import { reproject } from "bbox-fns";

/**
Expand Down Expand Up @@ -71,10 +71,6 @@ export const toRasterProjection = (
return feat;
} else if (raster.projection === 6933) {
const { forward } = proj4("EPSG:4326", "EPSG:6933");
proj4.defs(
"EPSG:6933",
"+proj=cea +lat_ts=30 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +type=crs"
);
return reprojectGeoJSONPlugable(feat, {
reproject: forward,
});
Expand All @@ -95,10 +91,6 @@ export const getRasterBoxSpherical = (raster: Georaster) => {
return bbox;
} else if (raster.projection === 6933) {
// Reproject back to spherical coordinates
proj4.defs(
"EPSG:6933",
"+proj=cea +lat_ts=30 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +type=crs"
);
const { inverse } = proj4("EPSG:4326", "EPSG:6933");
const rasterBbox: BBox = reproject(
[raster.xmin, raster.ymin, raster.xmax, raster.ymax],
Expand Down
9 changes: 9 additions & 0 deletions packages/geoprocessing/src/toolbox/proj4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import proj4 from "proj4";

// Add equal area projection - https://epsg.io/6933
proj4.defs(
"EPSG:6933",
"+proj=cea +lat_ts=30 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +type=crs"
);

export default proj4;

0 comments on commit f5cb2d9

Please sign in to comment.