@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
118 lines (117 loc) • 3.95 kB
TypeScript
import { Style } from 'ol/style.js';
import { Circle as CircleGeom, Geometry } from 'ol/geom.js';
import Feature from 'ol/Feature.js';
import IGirafeContext from '../context/icontext.js';
import DrawingState from './drawingState.js';
export declare enum DrawingShape {
Point = 0,
Polyline = 1,
Polygon = 2,
Square = 3,
Rectangle = 4,
Disk = 5,
FreehandPolyline = 6,
FreehandPolygon = 7
}
export type ArrowStyle = 'none' | 'start' | 'end' | 'both';
export type ArrowPosition = 'whole' | 'each' | 'mid';
export type LineStroke = 'full' | 'dash' | 'dot' | 'double';
export type MeasureInformation = 'none' | 'simple' | 'full';
export type SerializedFeature = {
n: string;
sc: string;
sw: number;
fc: string;
ls: string;
as: string;
ap: string;
nfz: number;
mfz: number;
f: string;
g: object;
dn: boolean;
mi: string;
nc: string;
mc: string;
s: boolean;
t: DrawingShape;
};
export default class DrawingFeature {
private readonly _tool;
private _name;
private _nameColor;
private _strokeColor;
private _strokeWidth;
private _fillColor;
private _lineStroke;
private _arrowStyle;
private _arrowPosition;
private _measureInformation;
private _nameFontSize;
private _measureFontSize;
private _measureColor;
private _font;
private _displayName;
private _selected;
geojson: object;
id: string;
onChange: (f: DrawingFeature) => void;
private readonly drawingState;
private readonly defaultDrawingConfig;
constructor(tool: DrawingShape, drawingState: DrawingState, drawingConfig: any);
get name(): string;
set name(v: string);
get strokeColor(): string;
set strokeColor(v: string);
get strokeWidth(): number;
set strokeWidth(v: number);
get lineStroke(): LineStroke;
set lineStroke(v: LineStroke);
get fillColor(): string;
set fillColor(v: string);
get arrowStyle(): ArrowStyle;
set arrowStyle(v: ArrowStyle);
get arrowPosition(): ArrowPosition;
set arrowPosition(v: ArrowPosition);
get nameFontSize(): number;
set nameFontSize(v: number);
get measureFontSize(): number;
set measureFontSize(v: number);
get font(): string;
set font(v: string);
get displayName(): boolean;
set displayName(v: boolean);
get measureInformation(): MeasureInformation;
set measureInformation(v: MeasureInformation);
get nameColor(): string;
set nameColor(v: string);
get measureColor(): string;
set measureColor(v: string);
get type(): DrawingShape;
get selected(): boolean;
set selected(v: boolean);
addToState(): void;
serialize(): SerializedFeature;
getLengthText(length: number): string;
getAreaText(area: number): string;
getCoordText(coord: number[]): string;
getAzimuthText(circle: CircleGeom): string;
isPointOrPolyline(): boolean;
getVertexStyle(activeNode?: boolean): Style;
static deserialize(serializedFeature: SerializedFeature, context: IGirafeContext, drawingState: DrawingState): DrawingFeature;
static circleToPolygon(center: number[], radius: number, nbEdges?: number): number[][];
static geojsonFromOlFeature(olFeature: Feature<Geometry>, shapeType: DrawingShape): object;
/**
* Create an ol feature instance from a geojson object, optionally simplifying circle geometries to polygons
* with a limited number of edges to improve support across formats and services.
*/
static olFeatureFromGeoJson(geoJson: any, circleToPolygonNbEdges?: number): Feature<Geometry>;
/**
* Finds a name composed of the shape type and a number.
* The number starts from how many shapes of the same type are already in the state +1.
* Then checks if such a candidate name already exists and increments if so.
* @param geometryTypename
* @returns
*/
private getDefaultName;
}