@extendz/extendz-openlayer
Version:
Extend UI Platform built on Angular Material
270 lines (269 loc) • 7.91 kB
TypeScript
/**
* Copyright 2018 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NgZone, EventEmitter, SimpleChanges } from '@angular/core';
import * as ol from 'openlayers';
import { TiffImage, OlOptions, LatLng, ReturnObject } from './models/index';
import { OpenLayerToolType } from './utils/index';
import { Observable } from 'rxjs/Observable';
export declare class ExtendzOpenlayerService {
private zone;
constructor(zone: NgZone);
/**
* Native Html elemet that holds the map
*/
mapElement: HTMLElement;
/**
* Emit drawn shape object to parent component
*/
onDraw: EventEmitter<any>;
/**
* Emit delete shape object to parent component
*/
private onDelete;
/**
* shape drawing start time
*/
private shapeDrawStartTime;
/**
* shape drawing end time
*/
private shapeDrawEndTime;
/**
* Object that hold customized POLYGON DRAW Interaction, source, vector,style
*/
polygonObject: any;
/**
* hold the current jobId
*/
jobID: number;
/**
* Hold the details of drawn shape.
*/
returnCoordinate: ReturnObject;
/**
* emit object on shped drawn or delete. array of ReturnObject.
*/
private returnCollection;
/**
* Object that hold customized POINT DRAW Interaction, source, vector,style
*/
pointObject: any;
/**
* determine wether feature is exist
*/
haveFeature: boolean;
/**
* determine wether feature is deleted
*/
featureDeleted: boolean;
/**
* hold deleted feature
*/
removedFeature: ol.Feature;
/**
* hold deleted feature style
*/
removedFeatureStyle: any;
/**
* hold active feature
*/
private currentFeatures;
private consantrationFeatures;
/**
* Images bounding location
*/
extent: any;
vectorSource: any;
vectorLayer: ol.layer.Vector;
feature: ol.Feature;
featurs: Array<ol.Feature>;
polygonFeaturs: Array<ol.Feature>;
pointFeaturs: Array<ol.Feature>;
singleCoordinats: ol.Coordinate;
coordinats: Array<ol.Coordinate>;
/**
*
*/
source: any;
drawStarted: boolean;
tiffImage: TiffImage;
/**
* Projection for the image. Since we use lat,lng we use EPSG:4326. Also we show a png image so the units will be pixels
*/
projection: ol.proj.Projection;
imageLayer: ol.layer.Image;
private drawType;
/**
* All map interactions
*/
private interactions;
private selectionInteraction;
/**
* Hold the map object
*/
map: ol.Map;
/**
* Drap and pan interaction.
* Activated only with middle mouse button.
*/
private dragPanInteraction;
/**
* Mouse Wheel zoom interaction.
*/
private mouseWheelZoomInteraction;
currentDraw: ol.interaction.Draw;
/**
* @method : initMap
* @author : Rumes
* @param olOption
* @returns void
* @description get the png image and extent and show it in the canves.
*/
initMap(olOption: OlOptions): void;
onChangeImage(changes: SimpleChanges, opt: OlOptions): void;
createImageLayer(options: OlOptions, tiffImage: TiffImage): void;
/**
* @method setTool
* @author Rumes
* @param tool
* @param color
* @param toolTypemarc antoni gretest hits
* @description manage the tool type
*/
setTool(tool: OpenLayerToolType, toolType?: string, color?: string): void;
/**
*
* @param tool
* @param toolType
* @param points
* @param color
* @author Rumes
* @description manage existin coordinates according to Draw Type
*/
setToolExist(tool: OpenLayerToolType, toolType: string, points: Array<LatLng>, color: string): void;
subcribeToMapEvent<E>(eventName: string): Observable<E>;
/**
* Before changing the tool clean up the old one.
*/
preSetTool(): void;
/**
* @method updatePointTool
* @author Rumes
* @param toolType
* @param color
* @description get the point tool type and according to them
* customize POINT interaction & assing to current Draw
*/
updatePointTool(toolType: string, color: string): void;
/**
* @method updatePoygonTool
* @author Rumes
* @param toolType
* @param color
* @description get the polygon tool type and according to them
* customize POLYGON interaction & assing to current Draw
*/
updatePolygonTool(toolType: string, color: string): void;
postSetTool(toolType: string): void;
/**
* @author Rumes
* @description create polygon using draw interaction
*/
createPolygon(toolType: string): void;
/**
* @author Rumes
* @author Randika Hapugoda
* @description create point using draw interaction
*/
createPoints(toolType: string): void;
finishDraw(): void;
undo(): void;
/**
*
* @param toolType
* @param points
* @author Rumes
* @description manage existing points according to Point Tool Type
*
*/
updatePointToolFromExist(toolType: string, points: Array<LatLng>, color: string): void;
/**
*
* @param toolType
* @param points
* @author Rumes
* @description manage existing polygon according to Polygon Tool Type
*
*/
updatePolygonToolFromExist(toolType: string, points: Array<LatLng>, color: string): void;
/**
*
* @param points
* @param type
* @param style
* @author Rumes
* @description create vector using existing lat lang coordinates
*/
createFeatureVector(points: Array<LatLng>, type: string, style?: ol.style.Style): void;
/**
*
* @param points
* @author Rumes
* @description Convert LatLang Array in to cordinates array
*/
latLangtoCoordinate(points: Array<LatLng>): void;
toogleSelectMode(): void;
/**
*
* @param feature
* @author Rumes
* @description Remove the passed Feature from the Vector Source
*/
deleteFeature(feature: ol.Feature): void;
/**
* Subscribe to draw current draw event.
*
* @author Randika Hapugoda
* @param eventName
*/
subcribeToCurrentDrawEvent<E>(eventName: string): Observable<ol.interaction.Draw.Event>;
subcribeToSourceEvent<E>(eventName: string): Observable<E>;
subcribeToViewPortEvent<E>(eventName: string): Observable<E>;
subcribeToSelectEvent<E>(eventName: string): Observable<ol.interaction.Select.Event>;
/**
* @author Rumes
* @description Reset last deleted feature
*/
undoDelete(): void;
/**
*
* @param cordinates
* @returns Array of LatLng objects
* @author Rumes
* @description get array of cordinates and convert to Array of LatLng Objects
*/
coordinatsToLatLng(cordinates: ol.Coordinate[]): Array<LatLng>;
/**
*
* @param geom
* @param drawTool
* @author Rumes
* @description get the feature geomatry and return ReturnObject
*/
getCoordinatsFromGeometry(removedFeature: ol.Feature, drawTool?: string, duration?: number): ReturnObject;
addExistingFeaturs(features: Array<ol.Feature>): void;
checkInFeaturesArray(feature: ol.Feature): void;
}