Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multi layers for GEE maps #69

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"workbench.colorCustomizations": {
"activityBar.background": "#4e0663",
"titleBar.activeBackground": "#280333",
"titleBar.activeForeground": "#e7e7e7",
"activityBar.activeBackground": "#4e0663",
"activityBar.activeBorder": "#785f07",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#785f07",
"activityBarBadge.foreground": "#e7e7e7",
"statusBar.background": "#280333",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#4e0663",
"titleBar.inactiveBackground": "#28033399",
"titleBar.inactiveForeground": "#e7e7e799",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#4e0663",
"statusBarItem.remoteBackground": "#280333",
"statusBarItem.remoteForeground": "#e7e7e7"
},
"peacock.color": "#280333"
}
7 changes: 5 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,8 @@
}
}
},
"defaultProject": "imagery-tester"
}
"defaultProject": "imagery-tester",
"cli": {
"analytics": false
}
}
2 changes: 1 addition & 1 deletion imagery-cesium/maps/cesium-map/cesium-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { IPixelPositionMovement, IPixelPosition } from '../../models/map-events'
declare const Cesium: any;

Cesium.buildModuleUrl.setBaseUrl('assets/Cesium/');
Cesium.BingMapsApi.defaultKey = 'AnjT_wAj_juA_MsD8NhcEAVSjCYpV-e50lUypkWm1JPxVu0XyVqabsvD3r2DQpX-';
// Cesium.BingMapsApi.defaultKey = 'AnjT_wAj_juA_MsD8NhcEAVSjCYpV-e50lUypkWm1JPxVu0XyVqabsvD3r2DQpX-';

export const CesiumMapName = 'CesiumMap';

Expand Down
87 changes: 61 additions & 26 deletions imagery-ol/mapSourceProviders/open-layers-GEE-source-provider.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
import XYZ from 'ol/source/XYZ';
import XYZ from "ol/source/XYZ";
import {
CacheService,
ImageryCommunicatorService,
ImageryMapSource,
IMapSettings, IMapSourceProvidersConfig,
MAP_SOURCE_PROVIDERS_CONFIG
} from '@ansyn/imagery';
import { IMAGE_PROCESS_ATTRIBUTE, OpenLayersMapSourceProvider } from './open-layers.map-source-provider';
import { OpenLayersMap } from '../maps/open-layers-map/openlayers-map/openlayers-map';
import { OpenLayersDisabledMap } from '../maps/openlayers-disabled-map/openlayers-disabled-map';
import { HttpClient } from '@angular/common/http';
import { Inject } from '@angular/core';
IMapSettings,
IMapSourceProvidersConfig,
MAP_SOURCE_PROVIDERS_CONFIG,
} from "@ansyn/imagery";
import {
IMAGE_PROCESS_ATTRIBUTE,
OpenLayersMapSourceProvider,
} from "./open-layers.map-source-provider";
import { OpenLayersMap } from "../maps/open-layers-map/openlayers-map/openlayers-map";
import { OpenLayersDisabledMap } from "../maps/openlayers-disabled-map/openlayers-disabled-map";
import { HttpClient } from "@angular/common/http";
import { Inject } from "@angular/core";

export const OpenLayerGEESourceProviderSourceType = 'GEE';
export const OpenLayerGEESourceProviderSourceType = "GEE";
@ImageryMapSource({
sourceType: OpenLayerGEESourceProviderSourceType,
supported: [OpenLayersMap, OpenLayersDisabledMap]
supported: [OpenLayersMap, OpenLayersDisabledMap],
})
export class OpenLayerGEESourceProvider extends OpenLayersMapSourceProvider {

layerData: any;

constructor(protected httpClient: HttpClient,
protected cacheService: CacheService,
protected imageryCommunicatorService: ImageryCommunicatorService,
@Inject(MAP_SOURCE_PROVIDERS_CONFIG) protected mapSourceProvidersConfig: IMapSourceProvidersConfig) {
super(cacheService, imageryCommunicatorService, mapSourceProvidersConfig);
constructor(
protected httpClient: HttpClient,
protected cacheService: CacheService,
protected imageryCommunicatorService: ImageryCommunicatorService,
@Inject(MAP_SOURCE_PROVIDERS_CONFIG)
protected mapSourceProvidersConfig: IMapSourceProvidersConfig
) {
super(
cacheService,
imageryCommunicatorService,
mapSourceProvidersConfig
);
}

async create(metaData: IMapSettings): Promise<any> {
Expand All @@ -38,23 +46,50 @@ export class OpenLayerGEESourceProvider extends OpenLayersMapSourceProvider {
const extent = this.createExtent(metaData);
const source = this.createSource(metaData);
const tileLayer = this.createLayer(source, extent);
tileLayer.set(IMAGE_PROCESS_ATTRIBUTE, this.getImageLayer(source, extent));
tileLayer.set(
IMAGE_PROCESS_ATTRIBUTE,
this.getImageLayer(source, extent)
);
return Promise.resolve(tileLayer);
}

/**
* this function was modified to use multiple layers with a single source, currently working clunky layer
* should be checked with the correct GEE server
* supports Angular 12
* @param metaData
* @returns
*/
createSource(metaData: IMapSettings): any {
const config = { ...this.config, ...metaData.data.config };
const geeDefs = JSON.parse(this.layerData.replace(/([\[\{,])\s*(\w+)\s*:/g, '$1 "$2":'));
const geeDefs = JSON.parse(
this.layerData.replace(/([\[\{,])\s*(\w+)\s*:/g, '$1 "$2":')
);
const urls = [];
geeDefs.layers.forEach((layer) => {
urls.push(
config.serverUrl +
`/query?request=` +
layer.requestType +
`&channel=` +
layer.id +
`&version=` +
layer.version +
`&x={x}&y={y}&z={z}`
);
});

const source = new XYZ({
url: config.serverUrl + `/query?request=` + geeDefs.layers[0].requestType + `&channel=` + geeDefs.layers[0].id + `&version=` + geeDefs.layers[0].version + `&x={x}&y={y}&z={z}`,
crossOrigin: 'anonymous',
minZoom: 1
urls: urls,
crossOrigin: "anonymous",
minZoom: 1,
});
return source;
}

getLayersData(serverURL: string): Promise<any> {
const fileUrl = serverURL + `/query?request=Json&is2d=t`;
return this.httpClient.get(fileUrl, { responseType: 'text' }).toPromise();
return this.httpClient
.get(fileUrl, { responseType: "text" })
.toPromise();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export abstract class OpenLayersMapSourceProvider<CONF = any> extends BaseMapSou
const extent = this.createExtent(metaData);
const source = this.createSource(metaData);
const tileLayer = this.createLayer(source, extent);
if (metaData.data["sourceUrl"]) {
source.setUrl(metaData.data["sourceUrl"]);
}
// if (metaData.data.overlay) {
// for image process;
tileLayer.set(IMAGE_PROCESS_ATTRIBUTE, this.getImageLayer(source, extent));
Expand Down
Loading