Browse Source

Removed extra formatting

pull/14155/head
LeoMorgan113 10 months ago
parent
commit
8fb976af4c
  1. 15
      ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/shapes-data-layer.ts
  2. 23
      ui-ngx/src/app/modules/home/components/widget/lib/maps/geo-map.ts
  3. 13
      ui-ngx/src/app/shared/models/widget/maps/map.models.ts

15
ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/shapes-data-layer.ts

@ -90,8 +90,7 @@ abstract class ShapePatternProcessor<S = any> {
} }
protected constructor(protected dataLayer: TbMapDataLayer, protected constructor(protected dataLayer: TbMapDataLayer,
protected settings: S) { protected settings: S) {}
}
public abstract setup(): Observable<any>; public abstract setup(): Observable<any>;
@ -122,10 +121,8 @@ abstract class ShapePatternProcessor<S = any> {
let pattern: L.TB.Pattern; let pattern: L.TB.Pattern;
if (patternInfo.type === ShapeFillType.color) { if (patternInfo.type === ShapeFillType.color) {
pattern = new L.TB.Pattern({width: 1, height: 1}); pattern = new L.TB.Pattern({width: 1, height: 1});
const fillRect = new L.TB.PatternRect({ const fillRect = new L.TB.PatternRect({x: 0, y: 0, width: 1, height: 1,
x: 0, y: 0, width: 1, height: 1, fillOpacity: 1, stroke: false, fill: true, fillColor: patternInfo.fillColor});
fillOpacity: 1, stroke: false, fill: true, fillColor: patternInfo.fillColor
});
pattern.addElement(fillRect); pattern.addElement(fillRect);
} else if (patternInfo.type === ShapeFillType.image) { } else if (patternInfo.type === ShapeFillType.image) {
const patternOptions: L.TB.PatternOptions = { const patternOptions: L.TB.PatternOptions = {
@ -133,7 +130,7 @@ abstract class ShapePatternProcessor<S = any> {
height: 1, height: 1,
patternUnits: 'objectBoundingBox', patternUnits: 'objectBoundingBox',
patternContentUnits: 'objectBoundingBox', patternContentUnits: 'objectBoundingBox',
viewBox: [0, 0, patternInfo.fillImage.width, patternInfo.fillImage.height] viewBox: [0,0,patternInfo.fillImage.width,patternInfo.fillImage.height]
}; };
if (patternInfo.fillImage.preserveAspectRatio) { if (patternInfo.fillImage.preserveAspectRatio) {
patternOptions.preserveAspectRatioAlign = 'xMidYMid'; patternOptions.preserveAspectRatioAlign = 'xMidYMid';
@ -306,7 +303,7 @@ class ShapeStripePatternProcessor extends ShapePatternProcessor<ShapeFillStripeS
} }
export abstract class TbShapesDataLayer<S extends ShapeDataLayerSettings, L extends TbLatestMapDataLayer<S, L>> extends TbLatestMapDataLayer<S, L> { export abstract class TbShapesDataLayer<S extends ShapeDataLayerSettings, L extends TbLatestMapDataLayer<S,L>> extends TbLatestMapDataLayer<S, L> {
private shapePatternProcessor: ShapePatternProcessor; private shapePatternProcessor: ShapePatternProcessor;
private strokeColorProcessor: DataLayerColorProcessor; private strokeColorProcessor: DataLayerColorProcessor;
@ -354,7 +351,7 @@ export abstract class TbShapesDataLayer<S extends ShapeDataLayerSettings, L exte
} }
protected allColorSettings(): DataLayerColorSettings[] { protected allColorSettings(): DataLayerColorSettings[] {
const colorSettings: DataLayerColorSettings[] = [this.settings.strokeColor]; const colorSettings: DataLayerColorSettings[] = [this.settings.strokeColor];
if (this.settings.fillType === ShapeFillType.color) { if (this.settings.fillType === ShapeFillType.color) {
colorSettings.push(this.settings.fillColor) colorSettings.push(this.settings.fillColor)
} else if (this.settings.fillType === ShapeFillType.stripe) { } else if (this.settings.fillType === ShapeFillType.stripe) {

23
ui-ngx/src/app/modules/home/components/widget/lib/maps/geo-map.ts

@ -61,16 +61,16 @@ export class TbGeoMap extends TbMap<GeoMapSettings> {
return of(map); return of(map);
} }
protected onResize(): void { protected onResize(): void {}
}
protected fitBounds(bounds: L.LatLngBounds) { protected fitBounds(bounds: L.LatLngBounds) {
if (bounds.isValid()) { if (bounds.isValid()) {
if (!this.settings.fitMapBounds && this.settings.defaultZoomLevel) { if (!this.settings.fitMapBounds && this.settings.defaultZoomLevel) {
this.map.setZoom(this.settings.defaultZoomLevel, {animate: false}); this.map.setZoom(this.settings.defaultZoomLevel, { animate: false });
if (this.settings.useDefaultCenterPosition) { if (this.settings.useDefaultCenterPosition) {
this.map.panTo(this.defaultCenterPosition, {animate: false}); this.map.panTo(this.defaultCenterPosition, { animate: false });
} else { }
else {
this.map.panTo(bounds.getCenter()); this.map.panTo(bounds.getCenter());
} }
} else { } else {
@ -80,13 +80,13 @@ export class TbGeoMap extends TbMap<GeoMapSettings> {
minZoom = Math.max(minZoom, this.settings.defaultZoomLevel); minZoom = Math.max(minZoom, this.settings.defaultZoomLevel);
} }
if (this.map.getZoom() > minZoom) { if (this.map.getZoom() > minZoom) {
this.map.setZoom(minZoom, {animate: false}); this.map.setZoom(minZoom, { animate: false });
} }
}); });
if (this.settings.useDefaultCenterPosition) { if (this.settings.useDefaultCenterPosition) {
bounds = bounds.extend(this.defaultCenterPosition); bounds = bounds.extend(this.defaultCenterPosition);
} }
this.map.fitBounds(bounds, {padding: [50, 50], animate: false}); this.map.fitBounds(bounds, { padding: [50, 50], animate: false });
this.map.invalidateSize(); this.map.invalidateSize();
} }
} }
@ -125,15 +125,12 @@ export class TbGeoMap extends TbMap<GeoMapSettings> {
); );
} }
public locationDataToLatLng(position: { x: number; y: number }): L.LatLng { public locationDataToLatLng(position: {x: number; y: number}): L.LatLng {
return L.latLng(position.x, position.y) as L.LatLng; return L.latLng(position.x, position.y) as L.LatLng;
} }
public latLngToLocationData(position: L.LatLng): { x: number; y: number } { public latLngToLocationData(position: L.LatLng): {x: number; y: number} {
position = position ? latLngPointToBounds(position, this.southWest, this.northEast, 0) : { position = position ? latLngPointToBounds(position, this.southWest, this.northEast, 0) : {lat: null, lng: null} as L.LatLng;
lat: null,
lng: null
} as L.LatLng;
return { return {
x: position.lat, x: position.lat,
y: position.lng y: position.lng

13
ui-ngx/src/app/shared/models/widget/maps/map.models.ts

@ -162,6 +162,7 @@ export interface DataLayerEditSettings {
snappable: boolean; snappable: boolean;
} }
export interface MapDataLayerSettings extends MapDataSourceSettings { export interface MapDataLayerSettings extends MapDataSourceSettings {
additionalDataSources?: MapDataSourceSettings[]; additionalDataSources?: MapDataSourceSettings[];
additionalDataKeys?: DataKey[]; additionalDataKeys?: DataKey[];
@ -910,7 +911,7 @@ export const defaultBaseMapSettings: BaseMapSettings = {
tripTimeline: { tripTimeline: {
showTimelineControl: false, showTimelineControl: false,
timeStep: 1000, timeStep: 1000,
speedOptions: [1, 5, 10, 15, 25], speedOptions: [1,5,10,15,25],
showTimestamp: true, showTimestamp: true,
timestampFormat: simpleDateFormat('yyyy-MM-dd HH:mm:ss'), timestampFormat: simpleDateFormat('yyyy-MM-dd HH:mm:ss'),
snapToRealLocation: false, snapToRealLocation: false,
@ -1282,7 +1283,7 @@ export type MapStringFunction = (data: FormattedData<TbMapDatasource>,
dsData: FormattedData<TbMapDatasource>[]) => string; dsData: FormattedData<TbMapDatasource>[]) => string;
export type MapBooleanFunction = (data: FormattedData<TbMapDatasource>, export type MapBooleanFunction = (data: FormattedData<TbMapDatasource>,
dsData: FormattedData<TbMapDatasource>[]) => boolean; dsData: FormattedData<TbMapDatasource>[]) => boolean;
export type MarkerImageFunction = (data: FormattedData<TbMapDatasource>, markerImages: string[], export type MarkerImageFunction = (data: FormattedData<TbMapDatasource>, markerImages: string[],
dsData: FormattedData<TbMapDatasource>[]) => MarkerImageInfo; dsData: FormattedData<TbMapDatasource>[]) => MarkerImageInfo;
@ -1342,7 +1343,7 @@ export const isValidLatLng = (latitude: any, longitude: any): boolean =>
isValidLatitude(latitude) && isValidLongitude(longitude); isValidLatitude(latitude) && isValidLongitude(longitude);
export const isCutPolygon = (data: TbPolygonCoordinates | TbPolygonRawCoordinates): boolean => { export const isCutPolygon = (data: TbPolygonCoordinates | TbPolygonRawCoordinates): boolean => {
return data.length > 1 && Array.isArray(data[0]) && (Array.isArray(data[0][0]) || (isNumber((data[0][0] as any).lat) && isNumber((data[0][0] as any).lng))); return data.length > 1 && Array.isArray(data[0]) && (Array.isArray(data[0][0]) || (isNumber((data[0][0] as any).lat) && isNumber((data[0][0] as any).lng)) );
} }
export const parseCenterPosition = (position: string | [number, number]): [number, number] => { export const parseCenterPosition = (position: string | [number, number]): [number, number] => {
@ -1426,7 +1427,7 @@ const mergeMapDatasource = (target: TbMapDatasource, source: TbMapDatasource): T
return target; return target;
} }
const imageAspectMap: { [key: string]: ImageWithAspect } = {}; const imageAspectMap: {[key: string]: ImageWithAspect} = {};
const imageLoader = (imageUrl: string): Observable<HTMLImageElement> => new Observable((observer: Observer<HTMLImageElement>) => { const imageLoader = (imageUrl: string): Observable<HTMLImageElement> => new Observable((observer: Observer<HTMLImageElement>) => {
const image = document.createElement('img'); // support IE const image = document.createElement('img'); // support IE
@ -1473,7 +1474,7 @@ export const loadImageWithAspect = (imagePipe: ImagePipe, imageUrl: string): Obs
url, url,
width: size[0], width: size[0],
height: size[1], height: size[1],
aspect: size[0] / size[1] aspect: size[0]/size[1]
}; };
imageAspectMap[hash] = imageWithAspect; imageAspectMap[hash] = imageWithAspect;
return imageWithAspect; return imageWithAspect;
@ -1551,7 +1552,7 @@ export const latLngPointToBounds = (point: L.LatLng, southWest: L.LatLng, northE
return point; return point;
} }
export type TripRouteData = { [time: number]: FormattedData<TbMapDatasource> }; export type TripRouteData = {[time: number]: FormattedData<TbMapDatasource>};
export const calculateInterpolationRatio = (firsMoment: number, secondMoment: number, intermediateMoment: number): number => { export const calculateInterpolationRatio = (firsMoment: number, secondMoment: number, intermediateMoment: number): number => {
return (intermediateMoment - firsMoment) / (secondMoment - firsMoment); return (intermediateMoment - firsMoment) / (secondMoment - firsMoment);

Loading…
Cancel
Save