Commit 3280df3b9c5f02a2f79f9bdbded8a36a6ced5956

Authored by Igor Kulikov
Committed by GitHub
2 parents 9e860a3b 7a87e6c1

Merge branch 'develop/3.0' into map/3.0

@@ -258,11 +258,11 @@ sql: @@ -258,11 +258,11 @@ sql:
258 ttl: 258 ttl:
259 ts: 259 ts:
260 enabled: "${SQL_TTL_TS_ENABLED:true}" 260 enabled: "${SQL_TTL_TS_ENABLED:true}"
261 - execution_interval_ms: "${SQL_TTL_TS_EXECUTION_INTERVAL:86400000}" # Number of miliseconds. The current value corresponds to one day 261 + execution_interval_ms: "${SQL_TTL_TS_EXECUTION_INTERVAL:86400000}" # Number of milliseconds. The current value corresponds to one day
262 ts_key_value_ttl: "${SQL_TTL_TS_TS_KEY_VALUE_TTL:0}" # Number of seconds 262 ts_key_value_ttl: "${SQL_TTL_TS_TS_KEY_VALUE_TTL:0}" # Number of seconds
263 events: 263 events:
264 enabled: "${SQL_TTL_EVENTS_ENABLED:true}" 264 enabled: "${SQL_TTL_EVENTS_ENABLED:true}"
265 - execution_interval_ms: "${SQL_TTL_EVENTS_EXECUTION_INTERVAL:86400000}" # Number of miliseconds. The current value corresponds to one day 265 + execution_interval_ms: "${SQL_TTL_EVENTS_EXECUTION_INTERVAL:86400000}" # Number of milliseconds. The current value corresponds to one day
266 events_ttl: "${SQL_TTL_EVENTS_EVENTS_TTL:0}" # Number of seconds 266 events_ttl: "${SQL_TTL_EVENTS_EVENTS_TTL:0}" # Number of seconds
267 debug_events_ttl: "${SQL_TTL_EVENTS_DEBUG_EVENTS_TTL:604800}" # Number of seconds. The current value corresponds to one week 267 debug_events_ttl: "${SQL_TTL_EVENTS_DEBUG_EVENTS_TTL:604800}" # Number of seconds. The current value corresponds to one week
268 268
@@ -34,7 +34,7 @@ public class MqttNoSqlTestSuite { @@ -34,7 +34,7 @@ public class MqttNoSqlTestSuite {
34 @ClassRule 34 @ClassRule
35 public static CustomSqlUnit sqlUnit = new CustomSqlUnit( 35 public static CustomSqlUnit sqlUnit = new CustomSqlUnit(
36 Arrays.asList("sql/schema-entities-hsql.sql", "sql/system-data.sql"), 36 Arrays.asList("sql/schema-entities-hsql.sql", "sql/system-data.sql"),
37 - "sql/drop-all-tables.sql", 37 + "sql/hsql/drop-all-tables.sql",
38 "nosql-test.properties"); 38 "nosql-test.properties");
39 39
40 @ClassRule 40 @ClassRule
@@ -391,6 +391,7 @@ public class JsonConverter { @@ -391,6 +391,7 @@ public class JsonConverter {
391 break; 391 break;
392 case JSON_V: 392 case JSON_V:
393 result.add(de.getKv().getKey(), JSON_PARSER.parse(de.getKv().getJsonV())); 393 result.add(de.getKv().getKey(), JSON_PARSER.parse(de.getKv().getJsonV()));
  394 + break;
394 default: 395 default:
395 throw new IllegalArgumentException("Unsupported data type: " + de.getKv().getType()); 396 throw new IllegalArgumentException("Unsupported data type: " + de.getKv().getType());
396 } 397 }
@@ -32,7 +32,7 @@ public class NoSqlDaoServiceTestSuite { @@ -32,7 +32,7 @@ public class NoSqlDaoServiceTestSuite {
32 @ClassRule 32 @ClassRule
33 public static CustomSqlUnit sqlUnit = new CustomSqlUnit( 33 public static CustomSqlUnit sqlUnit = new CustomSqlUnit(
34 Arrays.asList("sql/schema-entities-hsql.sql", "sql/schema-entities-idx.sql", "sql/system-data.sql", "sql/system-test.sql"), 34 Arrays.asList("sql/schema-entities-hsql.sql", "sql/schema-entities-idx.sql", "sql/system-data.sql", "sql/system-test.sql"),
35 - "sql/drop-all-tables.sql", 35 + "sql/hsql/drop-all-tables.sql",
36 "nosql-test.properties" 36 "nosql-test.properties"
37 ); 37 );
38 38
@@ -177,6 +177,7 @@ public abstract class TbAbstractGetAttributesNode<C extends TbGetAttributesNodeC @@ -177,6 +177,7 @@ public abstract class TbAbstractGetAttributesNode<C extends TbGetAttributesNodeC
177 } catch (IOException e) { 177 } catch (IOException e) {
178 throw new JsonParseException("Can't parse jsonValue: " + r.getJsonValue().get(), e); 178 throw new JsonParseException("Can't parse jsonValue: " + r.getJsonValue().get(), e);
179 } 179 }
  180 + break;
180 } 181 }
181 msg.getMetaData().putValue(r.getKey(), value.toString()); 182 msg.getMetaData().putValue(r.getKey(), value.toString());
182 } 183 }
@@ -70,10 +70,8 @@ export class TelemetryWebsocketService implements TelemetryService { @@ -70,10 +70,8 @@ export class TelemetryWebsocketService implements TelemetryService {
70 private ngZone: NgZone, 70 private ngZone: NgZone,
71 @Inject(WINDOW) private window: Window) { 71 @Inject(WINDOW) private window: Window) {
72 this.store.pipe(select(selectIsAuthenticated)).subscribe( 72 this.store.pipe(select(selectIsAuthenticated)).subscribe(
73 - (authenticated: boolean) => {  
74 - if (!authenticated) {  
75 - this.reset(true);  
76 - } 73 + () => {
  74 + this.reset(true);
77 } 75 }
78 ); 76 );
79 77
@@ -40,7 +40,6 @@ export default abstract class LeafletMap { @@ -40,7 +40,6 @@ export default abstract class LeafletMap {
40 markers: Map<string, Marker> = new Map(); 40 markers: Map<string, Marker> = new Map();
41 polylines: Map<string, Polyline> = new Map(); 41 polylines: Map<string, Polyline> = new Map();
42 polygons: Map<string, Polygon> = new Map(); 42 polygons: Map<string, Polygon> = new Map();
43 - dragMode = false;  
44 map: L.Map; 43 map: L.Map;
45 map$: BehaviorSubject<L.Map> = new BehaviorSubject(null); 44 map$: BehaviorSubject<L.Map> = new BehaviorSubject(null);
46 ready$: Observable<L.Map> = this.map$.pipe(filter(map => !!map)); 45 ready$: Observable<L.Map> = this.map$.pipe(filter(map => !!map));
@@ -240,7 +239,7 @@ export default abstract class LeafletMap { @@ -240,7 +239,7 @@ export default abstract class LeafletMap {
240 239
241 convertToCustomFormat(position: L.LatLng): object { 240 convertToCustomFormat(position: L.LatLng): object {
242 return { 241 return {
243 - [this.options.latKeyName]: position.lat % 180, 242 + [this.options.latKeyName]: position.lat % 90,
244 [this.options.lngKeyName]: position.lng % 180 243 [this.options.lngKeyName]: position.lng % 180
245 } 244 }
246 } 245 }
@@ -75,7 +75,7 @@ const imageAspectMap = {}; @@ -75,7 +75,7 @@ const imageAspectMap = {};
75 75
76 function imageLoader(imageUrl: string): Observable<HTMLImageElement> { 76 function imageLoader(imageUrl: string): Observable<HTMLImageElement> {
77 return new Observable((observer: Observer<HTMLImageElement>) => { 77 return new Observable((observer: Observer<HTMLImageElement>) => {
78 - const image = new Image(); 78 + const image = document.createElement('img'); // support IE
79 image.style.position = 'absolute'; 79 image.style.position = 'absolute';
80 image.style.left = '-99999px'; 80 image.style.left = '-99999px';
81 image.style.top = '-99999px'; 81 image.style.top = '-99999px';
@@ -236,3 +236,13 @@ export function safeExecute(func: (...args: any[]) => any, params = []) { @@ -236,3 +236,13 @@ export function safeExecute(func: (...args: any[]) => any, params = []) {
236 } 236 }
237 return res; 237 return res;
238 } 238 }
  239 +
  240 +export function calculateNewPointCoordinate(coordinate: number, imageSize: number): number {
  241 + let pointCoordinate = coordinate / imageSize;
  242 + if (pointCoordinate < 0) {
  243 + pointCoordinate = 0;
  244 + } else if (pointCoordinate > 1) {
  245 + pointCoordinate = 1;
  246 + }
  247 + return pointCoordinate;
  248 +}
@@ -29,8 +29,8 @@ export class Marker { @@ -29,8 +29,8 @@ export class Marker {
29 data: FormattedData; 29 data: FormattedData;
30 dataSources: FormattedData[]; 30 dataSources: FormattedData[];
31 31
32 - constructor(location: L.LatLngExpression, public settings: MarkerSettings,  
33 - data?: FormattedData, dataSources?, onDragendListener?) { 32 + constructor(location: L.LatLngExpression, public settings: MarkerSettings,
  33 + data?: FormattedData, dataSources?, onDragendListener?) {
34 this.setDataSources(data, dataSources); 34 this.setDataSources(data, dataSources);
35 this.leafletMarker = L.marker(location, { 35 this.leafletMarker = L.marker(location, {
36 draggable: settings.draggableMarker 36 draggable: settings.draggableMarker
@@ -19,7 +19,7 @@ import LeafletMap from '../leaflet-map'; @@ -19,7 +19,7 @@ import LeafletMap from '../leaflet-map';
19 import { UnitedMapSettings } from '../map-models'; 19 import { UnitedMapSettings } from '../map-models';
20 import { Observable } from 'rxjs'; 20 import { Observable } from 'rxjs';
21 import { map, filter, switchMap } from 'rxjs/operators'; 21 import { map, filter, switchMap } from 'rxjs/operators';
22 -import { aspectCache, parseFunction } from '@home/components/widget/lib/maps/maps-utils'; 22 +import { aspectCache, calculateNewPointCoordinate, parseFunction } from '@home/components/widget/lib/maps/maps-utils';
23 23
24 const maxZoom = 4;// ? 24 const maxZoom = 4;// ?
25 25
@@ -79,9 +79,10 @@ export class ImageMap extends LeafletMap { @@ -79,9 +79,10 @@ export class ImageMap extends LeafletMap {
79 if (lastCenterPos) { 79 if (lastCenterPos) {
80 lastCenterPos.x *= w; 80 lastCenterPos.x *= w;
81 lastCenterPos.y *= h; 81 lastCenterPos.y *= h;
82 - /* this.ctx.$scope.$injector.get('$mdUtil').nextTick(() => {  
83 - this.map.panTo(center, { animate: false });  
84 - });*/ 82 + const center = this.pointToLatLng(lastCenterPos.x, lastCenterPos.y);
  83 + setTimeout(() => {
  84 + this.map.panTo(center, { animate: false });
  85 + }, 0);
85 } 86 }
86 } 87 }
87 88
@@ -97,7 +98,7 @@ export class ImageMap extends LeafletMap { @@ -97,7 +98,7 @@ export class ImageMap extends LeafletMap {
97 width *= maxZoom; 98 width *= maxZoom;
98 const prevWidth = this.width; 99 const prevWidth = this.width;
99 const prevHeight = this.height; 100 const prevHeight = this.height;
100 - if (this.width !== width) { 101 + if (this.width !== width || updateImage) {
101 this.width = width; 102 this.width = width;
102 this.height = width / this.aspect; 103 this.height = width / this.aspect;
103 if (!this.map) { 104 if (!this.map) {
@@ -134,7 +135,7 @@ export class ImageMap extends LeafletMap { @@ -134,7 +135,7 @@ export class ImageMap extends LeafletMap {
134 135
135 convertPosition(expression): L.LatLng { 136 convertPosition(expression): L.LatLng {
136 if (isNaN(expression[this.options.xPosKeyName]) || isNaN(expression[this.options.yPosKeyName])) return null; 137 if (isNaN(expression[this.options.xPosKeyName]) || isNaN(expression[this.options.yPosKeyName])) return null;
137 - Object.assign(expression, this.posFunction(expression[this.options.xPosKeyName], expression[this.options.yPosKeyName])) 138 + Object.assign(expression, this.posFunction(expression[this.options.xPosKeyName], expression[this.options.yPosKeyName]));
138 return this.pointToLatLng( 139 return this.pointToLatLng(
139 expression.x * this.width, 140 expression.x * this.width,
140 expression.y * this.height); 141 expression.y * this.height);
@@ -149,9 +150,10 @@ export class ImageMap extends LeafletMap { @@ -149,9 +150,10 @@ export class ImageMap extends LeafletMap {
149 } 150 }
150 151
151 convertToCustomFormat(position: L.LatLng): object { 152 convertToCustomFormat(position: L.LatLng): object {
  153 + const point = this.latLngToPoint(position);
152 return { 154 return {
153 - [this.options.xPosKeyName]: (position.lng + 180) / 360,  
154 - [this.options.yPosKeyName]: (position.lat + 180) / 360 155 + [this.options.xPosKeyName]: calculateNewPointCoordinate(point.x, this.width),
  156 + [this.options.yPosKeyName]: calculateNewPointCoordinate(point.y, this.height)
155 } 157 }
156 } 158 }
157 } 159 }