Skip to content

Commit 34fcfa8

Browse files
committed
chore: lint
1 parent d9adf2b commit 34fcfa8

File tree

3 files changed

+89
-22
lines changed

3 files changed

+89
-22
lines changed

src/core/index.android.ts

Lines changed: 77 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { AltitudeKey, DefaultLatLonKeys, GenericMapPos, LatitudeKey, LongitudeKey, MapPos, MapRange, MapVec, ScreenBounds, ScreenPos, setMapPosKeys } from './index.common';
2-
import { BaseNative } from '../index.common';
2+
import { BaseNative, _createImageSourceFromSrc } from '../index.common';
3+
import { Color } from '@nativescript/core';
34
export { LatitudeKey, LongitudeKey, MapPos, ScreenBounds, ScreenPos, setMapPosKeys };
45

56
export const CartoMapStyle = {
@@ -11,7 +12,7 @@ export const CartoMapStyle = {
1112
},
1213
get DARKMATTER() {
1314
return com.carto.layers.CartoBaseMapStyle.CARTO_BASEMAP_STYLE_DARKMATTER;
14-
}
15+
},
1516
};
1617

1718
export const ClickType = {
@@ -26,7 +27,7 @@ export const ClickType = {
2627
},
2728
get DUAL() {
2829
return com.carto.ui.ClickType.CLICK_TYPE_DUAL.swigValue();
29-
}
30+
},
3031
};
3132

3233
export class MapBounds<T = DefaultLatLonKeys> extends BaseNative<com.carto.core.MapBounds, {}> {
@@ -64,15 +65,14 @@ export class MapBounds<T = DefaultLatLonKeys> extends BaseNative<com.carto.core.
6465
}
6566
}
6667

67-
6868
export function fromNativeMapPos<T = DefaultLatLonKeys>(position: com.carto.core.MapPos) {
6969
if (!position) {
7070
return null;
7171
}
7272
return {
7373
[LatitudeKey]: position.getY(),
7474
[LongitudeKey]: position.getX(),
75-
[AltitudeKey]: position.getZ()
75+
[AltitudeKey]: position.getZ(),
7676
} as GenericMapPos<T>;
7777
}
7878
export function toNativeMapPos<T = DefaultLatLonKeys>(position: GenericMapPos<T> | com.carto.core.MapPos, ignoreAltitude = false) {
@@ -85,14 +85,14 @@ export function toNativeMapPos<T = DefaultLatLonKeys>(position: GenericMapPos<T>
8585
if (position[LongitudeKey] === undefined || position[LatitudeKey] === undefined) {
8686
throw new Error(`toNativeMapPos: missing lat/lon parameters in ${position}`);
8787
}
88-
const result = new com.carto.core.MapPos(position[LongitudeKey], position[LatitudeKey], (!ignoreAltitude && position[AltitudeKey] > 0) ? position[AltitudeKey] : 0);
88+
const result = new com.carto.core.MapPos(position[LongitudeKey], position[LatitudeKey], !ignoreAltitude && position[AltitudeKey] > 0 ? position[AltitudeKey] : 0);
8989
// ignore z for now as points can get under the map!
9090
return result;
9191
}
9292
export function fromNativeScreenPos(position: com.carto.core.ScreenPos) {
9393
return {
9494
x: position.getY(),
95-
y: position.getX()
95+
y: position.getX(),
9696
} as ScreenPos;
9797
}
9898
export function toNativeScreenPos(position: ScreenPos) {
@@ -101,6 +101,72 @@ export function toNativeScreenPos(position: ScreenPos) {
101101
}
102102
return new com.carto.core.ScreenPos(position.x, position.y);
103103
}
104+
105+
// export class Converter {
106+
// NColor = {
107+
// fromNative(value) {
108+
// if (typeof value === 'string') {
109+
// return value;
110+
// }
111+
// return value;
112+
// },
113+
// toNative(value): android.graphics.Color {
114+
// const theColor = value instanceof Color ? value : value._argb ? new Color(value._argb) : new Color(value);
115+
// return theColor.ios;
116+
// },
117+
// };
118+
// Color = {
119+
// fromNative(value) {
120+
// if (typeof value === 'string') {
121+
// return value;
122+
// }
123+
// return new Color((value as com.carto.graphics.Color).getARGB());
124+
// },
125+
// toNative(value) {
126+
// const theColor = value instanceof Color ? value : value._argb ? new Color(value._argb) : new Color(value);
127+
// return new com.carto.graphics.Color(theColor.r, theColor.g, theColor.b, theColor.a);
128+
// },
129+
// };
130+
// MapRange = {
131+
// fromNative(value) {
132+
// return value;
133+
// },
134+
// toNative(value) {
135+
// const theColor = value instanceof Color ? value : value._argb ? new Color(value._argb) : new Color(value);
136+
// return theColor.ios;
137+
// },
138+
// };
139+
// Font = {
140+
// fromNative(value) {
141+
// // no easy from typeface to Font
142+
// return value;
143+
// },
144+
// toNative(value) {
145+
// return value?.getAndroidTypeface();
146+
// },
147+
// };
148+
// CartoImage = {
149+
// fromNative(value) {
150+
// // no easy from typeface to Font
151+
// return value;
152+
// },
153+
// toNative(value) {
154+
// value = _createImageSourceFromSrc(value);
155+
// return com.carto.utils.BitmapUtils.createBitmapFromAndroidBitmap(value.android as android.graphics.Bitmap);
156+
// },
157+
// };
158+
// AndroidEnum(androidEnum) {
159+
// return {
160+
// fromNative(value) {
161+
// // no easy from typeface to Font
162+
// return value.swigValue();
163+
// },
164+
// toNative(value) {
165+
// return androidEnum.swigToEnum(value);
166+
// },
167+
// };
168+
// }
169+
// }
104170
export function fromNativeMapRange(value: NTMapRange) {
105171
return [value.getMax(), value.getMin()] as MapRange;
106172
}
@@ -111,6 +177,7 @@ export function toNativeMapRange(value: MapRange) {
111177
// ignore z for now as points can get under the map!
112178
return new com.carto.core.MapRange(value[0], value[1]);
113179
}
180+
114181
export function toNativeMapVec(value: MapVec | [number, number, number]) {
115182
if (Array.isArray(value)) {
116183
return new com.carto.core.MapVec(value[0], value[1], value[2]);
@@ -120,11 +187,12 @@ export function toNativeMapVec(value: MapVec | [number, number, number]) {
120187
}
121188
return new com.carto.core.MapVec(value.x, value.y, value.z);
122189
}
190+
123191
export function fromNativeMapVec(value: com.carto.core.MapVec) {
124192
return {
125193
x: value.getX(),
126194
y: value.getY(),
127-
z: value.getZ()
195+
z: value.getZ(),
128196
} as MapVec;
129197
}
130198

@@ -151,7 +219,7 @@ export function toNativeMapBounds<T = DefaultLatLonKeys>(bounds: MapBounds<T>) {
151219
export function fromNativeScreenBounds(bounds: com.carto.core.ScreenBounds) {
152220
return {
153221
min: fromNativeScreenPos(bounds.getMin()),
154-
max: fromNativeScreenPos(bounds.getMax())
222+
max: fromNativeScreenPos(bounds.getMax()),
155223
} as ScreenBounds;
156224
}
157225
export function toNativeScreenBounds(bounds: ScreenBounds) {

src/core/index.common.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ export function setMapPosKeys(latitude: LatitudeKeys, longitude: LongitudeKeys,
4646
}
4747

4848
export function applyMixins(derivedCtor: any, baseCtors: any[]) {
49-
baseCtors.forEach(baseCtor => {
50-
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
49+
baseCtors.forEach((baseCtor) => {
50+
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
5151
if (name !== 'constructor') {
5252
derivedCtor.prototype[name] = baseCtor.prototype[name];
5353
}
5454
});
55-
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
55+
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
5656
const descriptor = Object.getOwnPropertyDescriptor(baseCtor.prototype, name);
5757

5858
if (name === 'constructor') return;
@@ -62,7 +62,7 @@ export function applyMixins(derivedCtor: any, baseCtors: any[]) {
6262
derivedCtor.prototype[name] = baseCtor.prototype[name];
6363
}
6464
});
65-
Object.getOwnPropertySymbols(baseCtor.prototype).forEach(symbol => {
65+
Object.getOwnPropertySymbols(baseCtor.prototype).forEach((symbol) => {
6666
derivedCtor.prototype[symbol] = baseCtor.prototype[symbol];
6767
});
6868
});

src/core/index.ios.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1+
import { BaseNative } from '../index.common';
12
import { AltitudeKey, DefaultLatLonKeys, GenericMapPos, LatitudeKey, LongitudeKey, MapPos, MapRange, MapVec, ScreenBounds, ScreenPos, setMapPosKeys } from './index.common';
23
export { LatitudeKey, LongitudeKey, MapPos, ScreenBounds, ScreenPos, setMapPosKeys };
3-
import { BaseNative } from '../index.common';
44

55
export enum CartoMapStyle {
66
VOYAGER = NTCartoBaseMapStyle.T_CARTO_BASEMAP_STYLE_VOYAGER,
77
POSITRON = NTCartoBaseMapStyle.T_CARTO_BASEMAP_STYLE_POSITRON,
8-
DARKMATTER = NTCartoBaseMapStyle.T_CARTO_BASEMAP_STYLE_DARKMATTER
8+
DARKMATTER = NTCartoBaseMapStyle.T_CARTO_BASEMAP_STYLE_DARKMATTER,
99
}
1010

1111
export enum ClickType {
1212
SINGLE = NTClickType.T_CLICK_TYPE_SINGLE,
1313
LONG = NTClickType.T_CLICK_TYPE_LONG,
1414
DOUBLE = NTClickType.T_CLICK_TYPE_DOUBLE,
15-
DUAL = NTClickType.T_CLICK_TYPE_DUAL
15+
DUAL = NTClickType.T_CLICK_TYPE_DUAL,
1616
}
1717

18-
1918
export class MapBounds<T = DefaultLatLonKeys> extends BaseNative<NTMapBounds, {}> {
2019
constructor(public northeast?: GenericMapPos<T>, public southwest?: GenericMapPos<T>, native?: NTMapBounds) {
2120
super(undefined, native);
@@ -66,7 +65,7 @@ export function fromNativeMapPos<T = DefaultLatLonKeys>(position: NTMapPos) {
6665
return {
6766
[LatitudeKey]: position.getY(),
6867
[LongitudeKey]: position.getX(),
69-
[AltitudeKey]: position.getZ()
68+
[AltitudeKey]: position.getZ(),
7069
} as GenericMapPos<T>;
7170
}
7271
export function toNativeMapPos<T = DefaultLatLonKeys>(position: GenericMapPos<T> | NTMapPos, ignoreAltitude = false) {
@@ -77,12 +76,12 @@ export function toNativeMapPos<T = DefaultLatLonKeys>(position: GenericMapPos<T>
7776
return position;
7877
}
7978
// ignore z for now as points can get under the map!
80-
return NTMapPos.alloc().initWithXYZ(position[LongitudeKey], position[LatitudeKey], (!ignoreAltitude && position[AltitudeKey] > 0) ? position[AltitudeKey] : 0);
79+
return NTMapPos.alloc().initWithXYZ(position[LongitudeKey], position[LatitudeKey], !ignoreAltitude && position[AltitudeKey] > 0 ? position[AltitudeKey] : 0);
8180
}
8281
export function fromNativeScreenPos(position: NTScreenPos) {
8382
return {
8483
x: position.getY(),
85-
y: position.getX()
84+
y: position.getX(),
8685
} as ScreenPos;
8786
}
8887
export function toNativeScreenPos(position: ScreenPos | NTScreenPos) {
@@ -115,7 +114,7 @@ export function fromNativeMapVec(value: NTMapVec) {
115114
return {
116115
x: value.getX(),
117116
y: value.getY(),
118-
z: value.getZ()
117+
z: value.getZ(),
119118
} as MapVec;
120119
}
121120

@@ -135,7 +134,7 @@ export function toNativeMapBounds<T = DefaultLatLonKeys>(bounds: MapBounds<T>) {
135134
export function fromNativeScreenBounds(bounds: NTScreenBounds) {
136135
return {
137136
min: fromNativeScreenPos(bounds.getMin()),
138-
max: fromNativeScreenPos(bounds.getMax())
137+
max: fromNativeScreenPos(bounds.getMax()),
139138
} as ScreenBounds;
140139
}
141140
export function toNativeScreenBounds(bounds: ScreenBounds) {

0 commit comments

Comments
 (0)