From dbfd4cfeb7e1c68268c4fee19c0a2bcae140b5e0 Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 11 May 2025 18:33:12 +0300 Subject: [PATCH 1/6] feat: Added missing api methods to VectorElement --- src/ui-carto/vectorelements/index.android.ts | 43 ++++++++++++++++++-- src/ui-carto/vectorelements/index.d.ts | 7 ++++ src/ui-carto/vectorelements/index.ios.ts | 42 +++++++++++++++++-- src/ui-carto/vectorelements/line.android.ts | 15 +++---- src/ui-carto/vectorelements/line.d.ts | 3 +- src/ui-carto/vectorelements/line.ios.ts | 12 ++---- 6 files changed, 94 insertions(+), 28 deletions(-) diff --git a/src/ui-carto/vectorelements/index.android.ts b/src/ui-carto/vectorelements/index.android.ts index dc03d9db..f4eb2344 100644 --- a/src/ui-carto/vectorelements/index.android.ts +++ b/src/ui-carto/vectorelements/index.android.ts @@ -2,11 +2,12 @@ import { AnimationStyle, BillboardStyleBuilderOptions, LineVectorElementOptions, // import { BaseVectorElement } from './vectorelements.common'; import { nativeProperty } from '../index.common'; import { BaseNative } from '../BaseNative'; -import { nativeMapToJS } from '../utils'; +import { JSVariantToNative, nativeMapToJS, nativeVariantToJS } from '../utils'; import { Projection } from '../projections'; -import { MapPos, MapPosVector, fromNativeMapPos, toNativeMapPos } from '../core'; +import { MapPos, MapPosVector, fromNativeMapBounds, fromNativeMapPos, toNativeMapPos } from '../core'; import { mapPosVectorFromArgs } from '..'; import { BaseVectorElementStyleBuilder } from './index.common'; +import { Geometry } from '../geometry'; export { BaseVectorElementStyleBuilder }; export const BillboardOrientation = { @@ -34,16 +35,17 @@ export const BillboardScaling = { }; export abstract class BaseVectorElement extends BaseNative { + @nativeProperty id: number; @nativeProperty visible: boolean; createNative(options: U) { return null; } + get metaData(): { [k: string]: string } { if (this.native) { return nativeMapToJS(this.native.getMetaData()); - } else { - return this.options.metaData; } + return this.options.metaData; } set metaData(value: { [k: string]: string }) { this.options.metaData = value; @@ -55,7 +57,40 @@ export abstract class BaseVectorElement extends BaseNative { + id?: number; visible?: boolean; metaData: { [k: string]: string }; + getBounds(): MapBounds; + getGeometry(): Geometry; + getMetadataElement(key: string): { [k: string]: string }; + setMetadataElement(key: string, element: { [k: string]: string }); + } export abstract class BasePointVectorElement, K = DefaultLatLonKeys> extends BaseVectorElement { position?: GenericMapPos; diff --git a/src/ui-carto/vectorelements/index.ios.ts b/src/ui-carto/vectorelements/index.ios.ts index 95b03ce6..fab5604a 100644 --- a/src/ui-carto/vectorelements/index.ios.ts +++ b/src/ui-carto/vectorelements/index.ios.ts @@ -1,9 +1,9 @@ import { AnimationStyle, BillboardStyleBuilderOptions, LineVectorElementOptions, PointVectorElementOptions, VectorElementOptions } from '.'; import { nativeProperty } from '../index.common'; import { BaseNative } from '../BaseNative'; -import { nativeMapToJS } from '../utils'; +import { JSVariantToNative, nativeMapToJS, nativeVariantToJS } from '../utils'; import { Projection } from '../projections'; -import { MapPos, MapPosVector, fromNativeMapPos, toNativeMapPos } from '../core'; +import { MapPos, MapPosVector, fromNativeMapBounds, fromNativeMapPos, toNativeMapPos } from '../core'; import { mapPosVectorFromArgs } from '..'; import { BaseVectorElementStyleBuilder } from './index.common'; export { BaseVectorElementStyleBuilder }; @@ -33,16 +33,17 @@ export const BillboardScaling = { }; export abstract class BaseVectorElement extends BaseNative { + @nativeProperty id: number; @nativeProperty visible: boolean; createNative(options: U) { return null; } + get metaData(): { [k: string]: string } { if (this.native) { return nativeMapToJS(this.native.getMetaData()); - } else { - return this.options.metaData; } + return this.options.metaData; } set metaData(value: { [k: string]: string }) { this.options.metaData = value; @@ -54,7 +55,40 @@ export abstract class BaseVectorElement extends BaseLineVectorElement | GenericMapPos[]); getPoses(): MapPosVector | GenericMapPos[]; getGeometry(): LineGeometry; - getBounds(): MapBounds; } diff --git a/src/ui-carto/vectorelements/line.ios.ts b/src/ui-carto/vectorelements/line.ios.ts index 00802560..6d8db6f4 100644 --- a/src/ui-carto/vectorelements/line.ios.ts +++ b/src/ui-carto/vectorelements/line.ios.ts @@ -1,6 +1,6 @@ import { Color } from '@nativescript/core'; import { geometryFromArgs, mapPosVectorFromArgs, nativeColorProperty, nativeProperty } from '..'; -import { MapBounds, MapPos, MapPosVector, fromNativeMapBounds } from '../core'; +import { MapBounds, MapPos, MapPosVector } from '../core'; import { LineGeometry } from '../geometry'; import { BaseVectorElementStyleBuilder } from './index.common'; import { BaseLineVectorElement } from './index.ios'; @@ -123,16 +123,12 @@ export class Line extends BaseLineVectorElement { getPoses() { return this.positions; } + get geometry(): LineGeometry { + return this.getGeometry(); + } set geometry(geometry: LineGeometry) { if (this.native) { this.native.setGeometry(geometryFromArgs(geometry)); } } - getGeometry() { - return this.getNative().getGeometry(); - } - getBounds() { - const nBounds = this.getNative().getBounds(); - return fromNativeMapBounds(nBounds); - } } From 6e473817699f784f954f75a03088184457d9b6aa Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 11 May 2025 18:59:13 +0300 Subject: [PATCH 2/6] fix: Corrected broken types and methods --- src/ui-carto/vectorelements/index.android.ts | 65 ++++++++++---------- src/ui-carto/vectorelements/index.d.ts | 14 ++--- src/ui-carto/vectorelements/index.ios.ts | 65 ++++++++++---------- src/ui-carto/vectorelements/line.android.ts | 33 +++++++--- src/ui-carto/vectorelements/line.d.ts | 1 + src/ui-carto/vectorelements/line.ios.ts | 14 ++++- 6 files changed, 112 insertions(+), 80 deletions(-) diff --git a/src/ui-carto/vectorelements/index.android.ts b/src/ui-carto/vectorelements/index.android.ts index f4eb2344..61b27cda 100644 --- a/src/ui-carto/vectorelements/index.android.ts +++ b/src/ui-carto/vectorelements/index.android.ts @@ -35,7 +35,6 @@ export const BillboardScaling = { }; export abstract class BaseVectorElement extends BaseNative { - @nativeProperty id: number; @nativeProperty visible: boolean; createNative(options: U) { return null; @@ -58,37 +57,6 @@ export abstract class BaseVectorElement { + @nativeProperty id: number; + + containsMetaDataKey(key: string): boolean { + return this.native ? this.native.containsMetaDataKey(key) : false; + } + + getBounds() { + if (this.native) { + return fromNativeMapBounds(this.native.getBounds()); + } + return null; + } + + getGeometry(): any { + if (this.native) { + return this.native.getGeometry(); + } + return null; + } + + getMetadataElement(key: string): { [k: string]: string } { + if (this.native) { + return nativeVariantToJS(this.native.getMetaDataElement(key)); + } + return undefined; + } + + setMetadataElement(key: string, element: { [k: string]: string }): void { + if (this.native) { + this.native.setMetaDataElement(key, JSVariantToNative(element)); + } + } + buildStyle() {} } diff --git a/src/ui-carto/vectorelements/index.d.ts b/src/ui-carto/vectorelements/index.d.ts index 36be189c..d80c2d91 100644 --- a/src/ui-carto/vectorelements/index.d.ts +++ b/src/ui-carto/vectorelements/index.d.ts @@ -56,14 +56,8 @@ export class BillboardStyleBuilderOptions extends VectorElementStyleBuilderOptio } export abstract class BaseVectorElement extends BaseNative { - id?: number; visible?: boolean; metaData: { [k: string]: string }; - getBounds(): MapBounds; - getGeometry(): Geometry; - getMetadataElement(key: string): { [k: string]: string }; - setMetadataElement(key: string, element: { [k: string]: string }); - } export abstract class BasePointVectorElement, K = DefaultLatLonKeys> extends BaseVectorElement { position?: GenericMapPos; @@ -77,7 +71,13 @@ export abstract class BaseLineVectorElement | GenericMapPos[]; projection?: Projection; } -export class VectorElement extends BaseVectorElement {} +export class VectorElement extends BaseVectorElement { + id?: number; + getBounds(): MapBounds; + getGeometry(): Geometry; + getMetadataElement(key: string): { [k: string]: string }; + setMetadataElement(key: string, element: { [k: string]: string }): void; +} export abstract class BaseVectorElementStyleBuilder extends BaseNative { buildStyle(): any; } diff --git a/src/ui-carto/vectorelements/index.ios.ts b/src/ui-carto/vectorelements/index.ios.ts index fab5604a..26a89e9e 100644 --- a/src/ui-carto/vectorelements/index.ios.ts +++ b/src/ui-carto/vectorelements/index.ios.ts @@ -33,7 +33,6 @@ export const BillboardScaling = { }; export abstract class BaseVectorElement extends BaseNative { - @nativeProperty id: number; @nativeProperty visible: boolean; createNative(options: U) { return null; @@ -56,37 +55,6 @@ export abstract class BaseVectorElement { + @nativeProperty id: number; + + containsMetaDataKey(key: string): boolean { + return this.native ? this.native.containsMetaDataKey(key) : false; + } + + getBounds() { + if (this.native) { + return fromNativeMapBounds(this.native.getBounds()); + } + return null; + } + + getGeometry(): any { + if (this.native) { + return this.native.getGeometry(); + } + return null; + } + + getMetadataElement(key: string): { [k: string]: string } { + if (this.native) { + return nativeVariantToJS(this.native.getMetaDataElement(key)); + } + return undefined; + } + + setMetadataElement(key: string, element: { [k: string]: string }): void { + if (this.native) { + this.native.setMetaDataElementElement(key, JSVariantToNative(element)); + } + } + buildStyle() {} } export class VectorElementVector extends BaseNative { diff --git a/src/ui-carto/vectorelements/line.android.ts b/src/ui-carto/vectorelements/line.android.ts index e84a1453..3426ab86 100644 --- a/src/ui-carto/vectorelements/line.android.ts +++ b/src/ui-carto/vectorelements/line.android.ts @@ -1,6 +1,6 @@ import { Color } from '@nativescript/core'; import { geometryFromArgs, mapPosVectorFromArgs, nativeColorProperty, nativeProperty } from '..'; -import { MapBounds, MapPos, MapPosVector } from '../core'; +import { fromNativeMapBounds, MapBounds, MapPos, MapPosVector } from '../core'; import { LineGeometry } from '../geometry'; import { BaseLineVectorElement } from './index.android'; import { BaseVectorElementStyleBuilder, styleBuilderProperty } from './index.common'; @@ -115,22 +115,39 @@ export class Line extends BaseLineVectorElement extends BaseLineVectorElement | GenericMapPos[]); getPoses(): MapPosVector | GenericMapPos[]; getGeometry(): LineGeometry; + getBounds(): MapBounds; } diff --git a/src/ui-carto/vectorelements/line.ios.ts b/src/ui-carto/vectorelements/line.ios.ts index 6d8db6f4..75d230b9 100644 --- a/src/ui-carto/vectorelements/line.ios.ts +++ b/src/ui-carto/vectorelements/line.ios.ts @@ -1,6 +1,6 @@ import { Color } from '@nativescript/core'; import { geometryFromArgs, mapPosVectorFromArgs, nativeColorProperty, nativeProperty } from '..'; -import { MapBounds, MapPos, MapPosVector } from '../core'; +import { fromNativeMapBounds, MapBounds, MapPos, MapPosVector } from '../core'; import { LineGeometry } from '../geometry'; import { BaseVectorElementStyleBuilder } from './index.common'; import { BaseLineVectorElement } from './index.ios'; @@ -131,4 +131,16 @@ export class Line extends BaseLineVectorElement { this.native.setGeometry(geometryFromArgs(geometry)); } } + getBounds() { + if (this.native) { + return fromNativeMapBounds(this.native.getBounds()); + } + return null; + } + getGeometry(): any { + if (this.native) { + return this.native.getGeometry(); + } + return null; + } } From d6cf7ab45de8926468ff03077736a8dd6bce35af Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 11 May 2025 19:55:58 +0300 Subject: [PATCH 3/6] fix: Added back removed getNative calls --- src/ui-carto/vectorelements/index.android.ts | 22 +++++------------- src/ui-carto/vectorelements/index.ios.ts | 22 +++++------------- src/ui-carto/vectorelements/line.android.ts | 24 +++++--------------- src/ui-carto/vectorelements/line.d.ts | 2 +- src/ui-carto/vectorelements/line.ios.ts | 16 ++++--------- 5 files changed, 24 insertions(+), 62 deletions(-) diff --git a/src/ui-carto/vectorelements/index.android.ts b/src/ui-carto/vectorelements/index.android.ts index 61b27cda..1c55106f 100644 --- a/src/ui-carto/vectorelements/index.android.ts +++ b/src/ui-carto/vectorelements/index.android.ts @@ -126,33 +126,23 @@ export class VectorElement extends BaseVectorElement { getPoses() { return this.positions; } - get geometry(): LineGeometry { + get geometry(): NTLineGeometry { return this.getGeometry(); } set geometry(geometry: LineGeometry) { @@ -131,16 +131,10 @@ export class Line extends BaseLineVectorElement { this.native.setGeometry(geometryFromArgs(geometry)); } } - getBounds() { - if (this.native) { - return fromNativeMapBounds(this.native.getBounds()); - } - return null; + getGeometry() { + return this.getNative().getGeometry(); } - getGeometry(): any { - if (this.native) { - return this.native.getGeometry(); - } - return null; + getBounds() { + return fromNativeMapBounds(this.getNative().getBounds()); } } From 9c997addd503168dd848ff1167fac725b556f4bd Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 11 May 2025 20:04:41 +0300 Subject: [PATCH 4/6] chore: linting --- src/ui-carto/vectorelements/index.android.ts | 1 - src/ui-carto/vectorelements/index.d.ts | 3 +-- src/ui-carto/vectorelements/line.android.ts | 2 +- src/ui-carto/vectorelements/line.d.ts | 3 +-- src/ui-carto/vectorelements/line.ios.ts | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ui-carto/vectorelements/index.android.ts b/src/ui-carto/vectorelements/index.android.ts index 1c55106f..f408bc4d 100644 --- a/src/ui-carto/vectorelements/index.android.ts +++ b/src/ui-carto/vectorelements/index.android.ts @@ -7,7 +7,6 @@ import { Projection } from '../projections'; import { MapPos, MapPosVector, fromNativeMapBounds, fromNativeMapPos, toNativeMapPos } from '../core'; import { mapPosVectorFromArgs } from '..'; import { BaseVectorElementStyleBuilder } from './index.common'; -import { Geometry } from '../geometry'; export { BaseVectorElementStyleBuilder }; export const BillboardOrientation = { diff --git a/src/ui-carto/vectorelements/index.d.ts b/src/ui-carto/vectorelements/index.d.ts index d80c2d91..47d923bc 100644 --- a/src/ui-carto/vectorelements/index.d.ts +++ b/src/ui-carto/vectorelements/index.d.ts @@ -1,7 +1,6 @@ import { BaseNative } from '..'; -import { MapPos, MapPosVector } from '../core'; +import { DefaultLatLonKeys, GenericMapPos, MapBounds, MapPos, MapPosVector } from '../core'; import { Projection } from '../projections'; -import { DefaultLatLonKeys, GenericMapPos } from '../core/index.common'; import { Geometry } from '../geometry'; declare enum BillboardOrientation { diff --git a/src/ui-carto/vectorelements/line.android.ts b/src/ui-carto/vectorelements/line.android.ts index f428e5ee..378727f0 100644 --- a/src/ui-carto/vectorelements/line.android.ts +++ b/src/ui-carto/vectorelements/line.android.ts @@ -1,6 +1,6 @@ import { Color } from '@nativescript/core'; import { geometryFromArgs, mapPosVectorFromArgs, nativeColorProperty, nativeProperty } from '..'; -import { fromNativeMapBounds, MapBounds, MapPos, MapPosVector } from '../core'; +import { MapBounds, MapPos, MapPosVector, fromNativeMapBounds } from '../core'; import { LineGeometry } from '../geometry'; import { BaseLineVectorElement } from './index.android'; import { BaseVectorElementStyleBuilder, styleBuilderProperty } from './index.common'; diff --git a/src/ui-carto/vectorelements/line.d.ts b/src/ui-carto/vectorelements/line.d.ts index 3feb4787..44684dfa 100644 --- a/src/ui-carto/vectorelements/line.d.ts +++ b/src/ui-carto/vectorelements/line.d.ts @@ -1,9 +1,8 @@ import { Projection } from '../projections'; -import { MapBounds, MapPosVector } from '../core'; +import { DefaultLatLonKeys, GenericMapPos, MapBounds, MapPosVector } from '../core'; import { BaseLineVectorElement, BaseVectorElementStyleBuilder, LineVectorElementOptions, VectorElementOptions } from '.'; import { Color } from '@nativescript/core'; import { Geometry, LineGeometry } from '../geometry'; -import { DefaultLatLonKeys, GenericMapPos } from '../core/index.common'; declare enum LineJointType { FaceCamera, diff --git a/src/ui-carto/vectorelements/line.ios.ts b/src/ui-carto/vectorelements/line.ios.ts index fedf5d2f..020bf281 100644 --- a/src/ui-carto/vectorelements/line.ios.ts +++ b/src/ui-carto/vectorelements/line.ios.ts @@ -1,6 +1,6 @@ import { Color } from '@nativescript/core'; import { geometryFromArgs, mapPosVectorFromArgs, nativeColorProperty, nativeProperty } from '..'; -import { fromNativeMapBounds, MapBounds, MapPos, MapPosVector } from '../core'; +import { MapBounds, MapPos, MapPosVector, fromNativeMapBounds } from '../core'; import { LineGeometry } from '../geometry'; import { BaseVectorElementStyleBuilder } from './index.common'; import { BaseLineVectorElement } from './index.ios'; From 4d3fab2ed60a72289a1b83fe1eb655fe06dad7d7 Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 11 May 2025 20:08:09 +0300 Subject: [PATCH 5/6] chore: import corrections --- src/ui-carto/ui/cssproperties.ts | 3 +-- src/ui-carto/vectorelements/group.d.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ui-carto/ui/cssproperties.ts b/src/ui-carto/ui/cssproperties.ts index bc67d1eb..35be7e74 100644 --- a/src/ui-carto/ui/cssproperties.ts +++ b/src/ui-carto/ui/cssproperties.ts @@ -1,6 +1,5 @@ import { CssProperty, Style, booleanConverter } from '@nativescript/core'; -import { LatitudeKey, LongitudeKey } from '../core'; -import { GenericMapPos } from '../core/index.common'; +import { GenericMapPos, LatitudeKey, LongitudeKey } from '../core'; export const zoomProperty = new CssProperty({ name: 'zoom', diff --git a/src/ui-carto/vectorelements/group.d.ts b/src/ui-carto/vectorelements/group.d.ts index 8b615224..e93a9537 100644 --- a/src/ui-carto/vectorelements/group.d.ts +++ b/src/ui-carto/vectorelements/group.d.ts @@ -1,7 +1,6 @@ import { BasePointVectorElement, PointVectorElementOptions, VectorElement, VectorElementVector } from '.'; -import { MapPos } from '../core'; +import { DefaultLatLonKeys, GenericMapPos, MapPos } from '../core'; import { Projection } from '../projections'; -import { DefaultLatLonKeys, GenericMapPos } from '../core/index.common'; export class GroupOptions extends PointVectorElementOptions { elements: { id: string; element: VectorElement }[]; From 626278597db25c014116d98032ba3fa3e47690ad Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Sun, 11 May 2025 20:14:19 +0300 Subject: [PATCH 6/6] ref: Making use of variant helper functions --- src/ui-carto/vectorelements/index.android.ts | 2 +- src/ui-carto/vectorelements/index.ios.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui-carto/vectorelements/index.android.ts b/src/ui-carto/vectorelements/index.android.ts index f408bc4d..4bd428a7 100644 --- a/src/ui-carto/vectorelements/index.android.ts +++ b/src/ui-carto/vectorelements/index.android.ts @@ -50,7 +50,7 @@ export abstract class BaseVectorElement