Skip to content

Commit

Permalink
WMS tile and projection support 1
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Jul 13, 2021
1 parent 436d379 commit f722647
Show file tree
Hide file tree
Showing 47 changed files with 2,945 additions and 321 deletions.
2,170 changes: 2,169 additions & 1 deletion dist/lithosphere.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/src/constants.d.ts

This file was deleted.

Empty file removed dist/src/controls/altitude.d.ts
Empty file.
15 changes: 0 additions & 15 deletions dist/src/controls/compass.d.ts

This file was deleted.

Empty file removed dist/src/controls/controls.d.ts
Empty file.
19 changes: 0 additions & 19 deletions dist/src/controls/coordinates.d.ts

This file was deleted.

Empty file removed dist/src/controls/crop.d.ts
Empty file.
18 changes: 0 additions & 18 deletions dist/src/controls/exaggerate.d.ts

This file was deleted.

13 changes: 0 additions & 13 deletions dist/src/controls/home.d.ts

This file was deleted.

17 changes: 0 additions & 17 deletions dist/src/controls/layers.d.ts

This file was deleted.

16 changes: 0 additions & 16 deletions dist/src/controls/walk.d.ts

This file was deleted.

12 changes: 12 additions & 0 deletions dist/src/core/CRS.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default class CRS {
options: any;
transformation: any;
projection: any;
_scales: number[];
R: number;
constructor(code: string, proj: string, options: any, radius: number);
project(latlng: any): any;
unproject(point: any, zoom: any): any;
pointToLatLng(point: any, zoom: any): any;
scale(zoom: number): number;
}
31 changes: 28 additions & 3 deletions dist/src/core/projection.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TileMapResource, LatLng, LatLngH, XYZ } from '../generalTypes';
import { TileMapResource, LatLng, LatLngH, XY, XYZ } from '../generalTypes';
interface Private {
tmp: null;
}
Expand All @@ -16,15 +16,40 @@ export default class Projection {
radiusScale: number;
radii: Radii;
tileMapResource: TileMapResource;
crs: any;
trueTileResolution: number;
res: any;
e: number;
ep: number;
flatteningFactor: number;
constructor(majorRadius?: number, minorRadius?: number, tileMapResource?: TileMapResource);
constructor(majorRadius?: number, minorRadius?: number, tileMapResource?: TileMapResource, trueTileResolution?: number);
_reset(): void;
setRadius: (radius: number, which?: RadiusE) => void;
invertY: (y: number, z: number) => number;
tileXYZ2LatLng: (x: number, y: number, z: number, flatXYZ: XYZ) => LatLng;
toBounds: (a: XY, b: XY) => {
min: {
x: any;
y: any;
};
max: {
x: any;
y: any;
};
};
tileXYZ2NwSe: (xyz: XYZ, tileResolution: number, asBounds?: boolean) => {
min: {
x: any;
y: any;
};
max: {
x: any;
y: any;
};
} | {
nw: any;
se: any;
};
tileXYZ2LatLng: (x: number, y: number, z: number, flatXYZ?: XYZ) => LatLng;
latLngZ2TileXYZ: (lat: number, lng: number, z: number, dontFloor?: boolean) => XYZ;
vector3ToLatLng: (xyz: XYZ) => LatLngH;
lonLatToVector3: (lon: number, lat: number, height: number) => XYZ;
Expand Down
Empty file removed dist/src/layers/curtain.d.ts
Empty file.
Empty file removed dist/src/layers/model.d.ts
Empty file.
Empty file removed dist/src/layers/overlay.d.ts
Empty file.
8 changes: 0 additions & 8 deletions dist/src/layers/tile.d.ts

This file was deleted.

Empty file removed dist/src/parsers/demt.d.ts
Empty file.
5 changes: 0 additions & 5 deletions dist/src/secondary/OrbitControls.d.ts

This file was deleted.

Empty file removed dist/src/secondary/PNG/zlib.d.ts
Empty file.
1 change: 0 additions & 1 deletion dist/src/secondary/PointerLockControls.d.ts

This file was deleted.

7 changes: 0 additions & 7 deletions dist/src/secondary/loadingScreen.d.ts

This file was deleted.

2 changes: 2 additions & 0 deletions dist/src/utils/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ declare const Utils: {
hexToRGB(hex: string): any;
rotatePoint(pt: any, center: any, angle: any): XY;
rotateAroundArbAxis(object: any, axis: any, radians: any, noPremultiply?: boolean): void;
getParamString(params: any, baseUrl: string, isUppercase?: boolean): string;
isArray(object: any): boolean;
};
export default Utils;
21 changes: 21 additions & 0 deletions dist/src/utils/paths.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
declare const Paths: {
buildPath: (format: string, basePath: string, tD: any, projection: any, tileResolution: number, options?: any, asObject?: boolean) => any;
wmsExtension: {
defaultWmsParams: {
SERVICE: string;
REQUEST: string;
FORMAT: string;
TRANSPARENT: boolean;
VERSION: string;
wmsVersion: any;
WIDTH: any;
HEIGHT: any;
};
extensionOptions: {
crsCode: string;
uppercase: boolean;
};
buildPath: (basePath: string, xyz: any, projection: any, tileResolution: number, options: any) => string;
};
};
export default Paths;
3 changes: 3 additions & 0 deletions docs/pages/Constructor/constructor.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ new LithoSphere(containerId, options)
| Parameter | Type | Default | Description |
| :--------------------: | :--------: | :--------------------------------------------------------------------------------: | :------------------------------------------------------------------------------: |
| **initialView** | _object_ | See [initialView]({{ site.baseurl }}/constructor#optionsinitialview) below | Sets the initial coordinate view of the scene |
| **majorRadius** | _integer_ | 6371000 | Major planetary radius in meters |
| **minorRadius** | _integer_ | majorRadius | Minor planetary radius in meters |
| **loadingScreen** | _boolean_ | true | If true, shows a loading screen until all lithosphere content first loads |
| **customParsers** | _object_ | See [Parsers]({{ site.baseurl }}/parsers) | Allows the use of custom elevation tile parsers |
| **tileMapResource** | _object_ | See [tileMapResource]({{ site.baseurl }}/constructor#optionstilemapresource) below | Configures projections |
Expand All @@ -40,6 +42,7 @@ new LithoSphere(containerId, options)
| **showAxes** | _boolean_ | false | If true, XYZ axes are rendered |
| **useLOD** | _boolean_ | true | If true, Level of Detail (LOD) tiles are rendered in the background |
| **LOD** | _object[]_ | See [LOD]({{ site.baseurl }}/constructor#optionslod) below | Fine tune Level of Detail (LOD) layers |
| **tileResolution** | _number_ | 32 | Square tile pixel dimension |
| **renderOnlyWhenOpen** | _boolean_ | true | Only update and render the scene if the containerId element has an non-zero area |
| **starsphere** | _object_ | See [starsphere]({{ site.baseurl }}/constructor#optionsstarsphere) below | Setup a skydome/skybox/skysphere |
| **atmosphere** | _object_ | See [atmosphere]({{ site.baseurl }}/constructor#optionsatmosphere) below | Setup an atmosphere for your planet |
Expand Down
7 changes: 5 additions & 2 deletions example.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@
'https://miplmmgis.jpl.nasa.gov/Missions/MSL/Layers/Gale_Aeolis_Palus/Gale_Aeolis_Palus/{z}/{x}/{y}.png',
demPath:
'https://miplmmgis.jpl.nasa.gov/Missions/MSL/Layers/MSL_CTX_DEM_mosaic_20m/{z}/{x}/{y}.png',
parser: 'All500',
//parser: 'All500',
// TODO: Implement format
format: 'tms', // 'wmts' || 'wms'
formatOptions: {},
demFormat: 'tms', //
demFormatOptions: {},
opacity: 1,
minZoom: 10,
maxZoom: 17,
Expand All @@ -102,6 +104,7 @@
-4.12495782349,
],
})

//Litho.removeLayer('Aeolis')

Litho.addLayer('tile', {
Expand All @@ -111,7 +114,7 @@
path:
'https://miplmmgis.jpl.nasa.gov/Missions/MSL/Layers/Gale_HiRISE/Gale_HiRISE/{z}/{x}/{y}.png',
demPath:
'https://miplmmgis.jpl.nasa.gov/public/HiRISE_D32/{z}/{x}/{y}.png',
'https://miplmmgis.jpl.nasa.gov/Missions/MSL/Layers/Gale_HiRISE/MSL_Gale_DEM_Mosaic_1m_v3/MSL_Gale_DEM_Mosaic_1m_v3/{z}/{x}/{y}.png',
format: 'tms', // 'wmts' || 'wms'
demFormat: 'tms', //
opacity: 1,
Expand Down
106 changes: 106 additions & 0 deletions example2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LithoSphere Demo</title>

<script src="./dist/lithosphere.js"></script>
<style>
html,
body {
width: 100%;
height: 100%;
margin: 0;
background: black;
}
#container {
width: 100%;
height: 100%;
overflow: hidden;
}
#myCustomCoordDiv {
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: white;
color: black;
padding: 2px 4px;
}
</style>
</head>
<body>
<div id="container"></div>
<!--<div id="myCustomCoordDiv"></div>-->
<script>
const Litho = new LithoSphere.default('container', {
initialView: {
lng: 0, // default 0
lat: 0,
zoom: 0,
},
majorRadius: 1737400,
customParsers: {
All500: (tilePath, layerObj) => {
return new Promise((resolve, reject) => {
const tileDimension = 32
resolve(
new Array(tileDimension * tileDimension).fill(
500
)
)
})
},
},
//opt
tileMapResource: {
//bounds: [-868700, -868700, 868700, 868700],
//origin: [-868700, -868700],
bounds: [-1737400, -1737400, 1737400, 1737400],
origin: [-1737400, 1737400],
crsCode: 'IAU2000:30166,0,0',
proj:
'+proj=stere +lat_0=0 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=1737400 +b=1737400 +units=m +no_defs', // proj4 string describing the global tileset projection: string (opt) | default wgs84
resunitsperpixel: 6786.71875,
reszoomlevel: 0,
},
//radiusOfTiles: 3,
//useLOD: false,
//wireframeMode: true,
starsphere: {
url:
'https://miplmmgis.jpl.nasa.gov/public/images/eso0932a.jpg',
color: '#444444',
},
atmosphere: {
color: '#222227',
},
})

console.log(Litho)

Litho.addLayer('tile', {
name: 'Global WAC',
order: 1, //Orders are ordered only within the layer type
on: true,
path:
'https://viperserv.jpl.nasa.gov/lunaserv/?layers=luna_wac_global',
demPath: null,
format: 'wms', // 'wmts' || 'wms' // wms requires a tileMapResource to be set to help compute tile bboxes
formatOptions: {},
demFormat: 'wms', //
demFormatOptions: {},
opacity: 1,
minZoom: 0,
maxZoom: 18,
})

Litho.addControl('myLayers', Litho.controls.layers)
Litho.addControl('myCompass', Litho.controls.compass)
Litho.addControl('myCoords', Litho.controls.coordinates, {
//existingDivId: 'myCustomCoordDiv',
})
</script>
</body>
</html>
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lithosphere",
"version": "1.0.0",
"description": "A GIS library for building 3D tile-based globes.",
"version": "1.0.1",
"description": "LithoSphere is a GIS JavaScript library for building 3D tile-based globes in the web browser.",
"author": "Tariq Soliman",
"license": "Apache-2.0",
"bugs": {
Expand Down
Loading

0 comments on commit f722647

Please sign in to comment.