Skip to content

gi-nx


gi-nx / toProjected

ts
function toProjected(fc: 
  | FeatureCollection<Geometry, {
[name: string]: any;
}>
  | Feature<Geometry, {
[name: string]: any;
}>, origin: [number, number]): 
  | Feature<Geometry, {
[name: string]: any;
}>
  | {
  features: Feature<Geometry, {
   [name: string]: any;
  }>[];
  type: string;
};

Convert geographic coordinates (lng/lat) to local meters relative to an origin point. Useful for CAD-style operations where you need to work in metric units.

Parameters

ParameterTypeDescription
fc| FeatureCollection<Geometry, { [name: string]: any; }> | Feature<Geometry, { [name: string]: any; }>Feature or FeatureCollection with lng/lat coordinates
origin[number, number]Reference point as [longitude, latitude] - becomes [0, 0] in output

Returns

| Feature<Geometry, { [name: string]: any; }> | { features: Feature<Geometry, { [name: string]: any; }>[]; type: string; }

Example

typescript
const origin = [-122.4194, 37.7749];
const projected = await rpc.invoke("toProjected", [myFeature, origin]);
// Coordinates are now in meters relative to origin