Skip to content

Commit fa444d8

Browse files
committed
chore: reafactor and fixes
1 parent d4f287b commit fa444d8

22 files changed

+76
-48
lines changed

src/core/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class MapBounds<T = DefaultLatLonKeys> extends BaseNative<any, {}> {
6666
equals(position: MapBounds<T>): boolean;
6767
getCenter(): GenericMapPos<T>;
6868
}
69+
// eslint-disable-next-line no-redeclare
6970
export interface MapBounds<T = DefaultLatLonKeys> {
7071
northeast: GenericMapPos<T>;
7172
southwest: GenericMapPos<T>;

src/geometry/feature.android.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ export class FeatureCollection implements IFeatureCollection {
1010
const nResult = this.native.getFeature(index);
1111
return {
1212
properties: nativeVariantToJS(nResult.getProperties()),
13-
geometry: nResult.getGeometry(),
13+
geometry: nResult.getGeometry() as any,
1414
} as Feature;
1515
}
1616
getGeometry(index: number) {
17-
return this.native.getFeature(index).getGeometry();
17+
return this.native.getFeature(index).getGeometry() as any;
1818
}
1919
getFeatureCount() {
2020
return this.native.getFeatureCount();
@@ -61,7 +61,7 @@ export class VectorTileFeatureCollection extends FeatureCollection {
6161
const nResult = this.native.getFeature(index) as com.carto.geometry.VectorTileFeature;
6262
return {
6363
properties: nativeVariantToJS(nResult.getProperties()),
64-
geometry: nResult.getGeometry(),
64+
geometry: nResult.getGeometry() as any,
6565
id: nResult.getId(),
6666
layerName: nResult.getLayerName()
6767
} as VectorTileFeature;

src/geometry/feature.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Geometry } from '.';
22

33
export interface Feature<T = DefaultLatLonKeys> {
4-
properties: {};
5-
geometry: Geometry<T> | any;
4+
properties: {[k: string]: any};
5+
geometry: Geometry<T>;
66
// getProperties(): any;
77

88
// getGeometry(): Geometry;
@@ -17,7 +17,7 @@ export interface VectorTileFeature extends Feature {
1717
export class FeatureCollection<T = DefaultLatLonKeys> {
1818
constructor(native: any);
1919
getFeature(index: number): Feature<T>;
20-
getGeometry(index: number): Geometry<T> | any;
20+
getGeometry(index: number): Geometry<T>;
2121
getFeatureCount(): number;
2222
readonly featureCount: number;
2323
getNative();

src/geometry/feature.ios.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { Feature, FeatureCollection as IFeatureCollection, VectorTileFeature } from './feature';
1+
import { LatitudeKey, LongitudeKey, MapBounds, fromNativeMapBounds } from '../core';
22
import { nativeVariantToJS } from '../utils';
3-
import { Geometry } from '.';
4-
import { DefaultLatLonKeys, fromNativeMapBounds, LatitudeKey, LongitudeKey, MapBounds } from '../core';
3+
import { Feature, FeatureCollection as IFeatureCollection, VectorTileFeature } from './feature';
54

65
export class FeatureCollection implements IFeatureCollection {
76
constructor(protected native: NTFeatureCollection) {}
@@ -63,7 +62,7 @@ export class VectorTileFeatureCollection extends FeatureCollection {
6362
const nResult = this.native.getFeature(index);
6463
return {
6564
properties: nativeVariantToJS(nResult.getProperties()),
66-
geometry: nResult.getGeometry(),
65+
geometry: nResult.getGeometry() as any,
6766
id: nResult.getId(),
6867
layerName: nResult.getLayerName(),
6968
} as VectorTileFeature;

src/geometry/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DefaultLatLonKeys, GenericMapPos, MapBounds, MapPos, MapPosVector } fro
22
import { BaseNative } from '../index.common';
33

44
export interface GeometryOptions<T = DefaultLatLonKeys> {}
5-
export abstract class Geometry<T = DefaultLatLonKeys, U extends GeometryOptions = GeometryOptions> extends BaseNative<any, U> {
5+
export abstract class Geometry<T = DefaultLatLonKeys, U extends GeometryOptions = GeometryOptions<T>> extends BaseNative<any, U> {
66
getCenterPos(): GenericMapPos<T>;
77
getBounds(): MapBounds<T>;
88
}

src/geometry/writer.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ export class GeoJSONGeometryWriter extends BaseNative<com.carto.geometry.GeoJSON
1111
return new com.carto.geometry.GeoJSONGeometryWriter();
1212
}
1313
writePoses(value: MapPosVector) {
14-
this.getNative().writeGeometry(new com.carto.geometry.LineGeometry(mapPosVectorFromArgs(value)));
14+
return this.getNative().writeGeometry(new com.carto.geometry.LineGeometry(mapPosVectorFromArgs(value)));
1515
}
1616
writeFeatureCollection(value: FeatureCollection) {
17-
this.getNative().writeFeatureCollection(featureCollectionFromArgs(value));
17+
return this.getNative().writeFeatureCollection(featureCollectionFromArgs(value));
1818
}
1919
set sourceProjection(value: Projection) {
2020
this.native && this.native.setSourceProjection(value.getNative());

src/geometry/writer.ios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ export class GeoJSONGeometryWriter extends BaseNative<NTGeoJSONGeometryWriter, G
1111
return NTGeoJSONGeometryWriter.alloc().init();
1212
}
1313
writePoses(value: MapPosVector) {
14-
this.getNative().writeGeometry(new NTLineGeometry(mapPosVectorFromArgs(value)));
14+
return this.getNative().writeGeometry(new NTLineGeometry(mapPosVectorFromArgs(value)));
1515
}
1616
writeFeatureCollection(value: FeatureCollection) {
17-
this.getNative().writeFeatureCollection(featureCollectionFromArgs(value));
17+
return this.getNative().writeFeatureCollection(featureCollectionFromArgs(value));
1818
}
1919
set sourceProjection(value: Projection) {
2020
this.native && this.native.setSourceProjection(value.getNative());

src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-redeclare */
12
import { Observable } from '@nativescript/core/data/observable';
23
import { DefaultLatLonKeys, GenericMapPos, MapPosVector, MapPosVectorVector } from './core';
34
import { FeatureCollection } from './geometry/feature';

src/vectorelements/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class BillboardVectorElementOptions<K = DefaultLatLonKeys> extends PointV
3737
rotation?: number;
3838
}
3939
export class LineVectorElementOptions<T = DefaultLatLonKeys> extends VectorElementOptions {
40-
positions: MapPosVector<T> | GenericMapPos<T>[];
40+
positions?: MapPosVector<T> | GenericMapPos<T>[];
4141
projection?: Projection;
4242
ignoreAltitude?: boolean;
4343
}
@@ -59,15 +59,15 @@ export abstract class BaseVectorElement<T, U extends VectorElementOptions> exten
5959
metaData: { [k: string]: string };
6060
}
6161
export abstract class BasePointVectorElement<T, U extends PointVectorElementOptions<K>, K = DefaultLatLonKeys> extends BaseVectorElement<T, U> {
62-
position: GenericMapPos<K>;
62+
position?: GenericMapPos<K>;
6363
projection?: Projection;
6464
getNativePos(pos: GenericMapPos<K>, projection?: Projection): any;
6565
}
6666
export abstract class BaseBillboardVectorElement<T, U extends BillboardVectorElementOptions<K>, K = DefaultLatLonKeys> extends BasePointVectorElement<T, U, K> {
6767
rotation?: number;
6868
}
6969
export abstract class BaseLineVectorElement<T, U extends LineVectorElementOptions<K>, K = DefaultLatLonKeys> extends BaseVectorElement<T, U> {
70-
positions: MapPosVector<K> | GenericMapPos<K>[];
70+
positions?: MapPosVector<K> | GenericMapPos<K>[];
7171
projection?: Projection;
7272
}
7373
export class VectorElement<T, U extends VectorElementOptions> extends BaseVectorElement<T, U> {}

src/vectorelements/line.android.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ export class Line extends BaseLineVectorElement<com.carto.vectorelements.Line, L
102102
}
103103
createNative(options: LineOptions) {
104104
const style = this.buildStyle();
105-
const result = new com.carto.vectorelements.Line(mapPosVectorFromArgs(options.positions, options.ignoreAltitude), style);
106-
// result['owner'] = new WeakRef(this);
107-
return result;
105+
if (options.positions) {
106+
return new com.carto.vectorelements.Line(mapPosVectorFromArgs(options.positions, options.ignoreAltitude), style);
107+
} else if (options.geometry) {
108+
return new com.carto.vectorelements.Line(geometryFromArgs(options.geometry), style);
109+
}
110+
return null;
108111
}
109112
buildStyle() {
110113
let style: com.carto.styles.LineStyle;

0 commit comments

Comments
 (0)