Skip to content

Commit 78a63a2

Browse files
committed
3.0.7
styles that are set on the FeatureTiles class override all GeoPackage styles
1 parent f4453cd commit 78a63a2

File tree

3 files changed

+71
-19
lines changed

3 files changed

+71
-19
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ The GeoPackage JavaScript library currently provides the ability to read GeoPack
3838

3939
### Changelog
4040

41+
##### 3.0.7
42+
43+
- Styles that are set on the FeatureTiles class will override any styles in the GeoPackage
44+
4145
##### 3.0.6
4246

4347
- Fix for styles for feature types ignoring case

lib/tiles/features/index.ts

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
// @ts-ignore
2-
import concat from 'concat-stream';
3-
// @ts-ignore
4-
import reproject from 'reproject';
52
import PolyToLine from '@turf/polygon-to-line';
63
import Simplify from '@turf/simplify';
7-
import proj4 from 'proj4';
4+
import concat from 'concat-stream';
85
import { Geometry } from 'geojson';
9-
10-
import { FeatureDao } from '../../features/user/featureDao';
11-
import { TileBoundingBoxUtils } from '../tileBoundingBoxUtils';
6+
import proj4 from 'proj4';
7+
// @ts-ignore
8+
import reproject from 'reproject';
129
import { BoundingBox } from '../../boundingBox';
13-
import { ImageUtils } from '../imageUtils';
10+
import { FeatureStyle } from '../../extension/style/featureStyle';
11+
import { FeatureTableStyles } from '../../extension/style/featureTableStyles';
1412
import { IconCache } from '../../extension/style/iconCache';
15-
import { GeometryCache } from './geometryCache';
13+
import { IconRow } from '../../extension/style/iconRow';
14+
import { StyleRow } from '../../extension/style/styleRow';
15+
import { FeatureDao } from '../../features/user/featureDao';
16+
import { FeatureRow } from '../../features/user/featureRow';
17+
import { GeoPackage } from '../../geoPackage';
18+
import { CrsGeometry } from '../../types/CrsGeometry';
19+
import { ImageUtils } from '../imageUtils';
20+
import { TileBoundingBoxUtils } from '../tileBoundingBoxUtils';
21+
import { CustomFeaturesTile } from './custom/customFeaturesTile';
1622
import { FeatureDrawType } from './featureDrawType';
1723
import { FeaturePaintCache } from './featurePaintCache';
18-
import { Paint } from './paint';
19-
import { FeatureTableStyles } from '../../extension/style/featureTableStyles';
20-
import { GeoPackage } from '../../geoPackage';
21-
import { FeatureRow } from '../../features/user/featureRow';
22-
import { StyleRow } from '../../extension/style/styleRow';
2324
import { FeatureTilePointIcon } from './featureTilePointIcon';
24-
import { CustomFeaturesTile } from './custom/customFeaturesTile';
25-
import { FeatureStyle } from '../../extension/style/featureStyle';
26-
import { IconRow } from '../../extension/style/iconRow';
27-
import { CrsGeometry } from '../../types/CrsGeometry';
25+
import { GeometryCache } from './geometryCache';
26+
import { Paint } from './paint';
27+
2828
/**
2929
* FeatureTiles module.
3030
* @module tiles/features
@@ -45,13 +45,19 @@ export class FeatureTiles {
4545
public compressFormat = 'png';
4646
public pointRadius = 4.0;
4747
pointPaint: Paint = new Paint();
48+
private _overrideGeoPackagePointPaint = false;
4849
public pointIcon: FeatureTilePointIcon = null;
4950
linePaint: Paint = new Paint();
51+
private _overrideGeoPackageLinePaint = false;
5052
private _lineStrokeWidth = 2.0;
53+
private _overrideGeoPackageLineStrokeWidth = false;
5154
polygonPaint: Paint = new Paint();
55+
private _overrideGeoPackagePolygonPaint = false;
5256
private _polygonStrokeWidth = 2.0;
57+
private _overrideGeoPackagePolygonStrokeWidth = false;
5358
public fillPolygon = true;
5459
polygonFillPaint: Paint = new Paint();
60+
private _overrideGeoPackagePolygonFillPaint = false;
5561
featurePaintCache: FeaturePaintCache = new FeaturePaintCache();
5662
geometryCache: GeometryCache = new GeometryCache();
5763
public cacheGeometries = true;
@@ -251,6 +257,9 @@ export class FeatureTiles {
251257
* @return paint
252258
*/
253259
getPointPaint(featureStyle: FeatureStyle): Paint {
260+
if (this._overrideGeoPackagePointPaint) {
261+
return this.pointPaint;
262+
}
254263
let paint = this.getFeatureStylePaint(featureStyle, FeatureDrawType.CIRCLE);
255264
if (paint == null) {
256265
paint = this.pointPaint;
@@ -263,6 +272,9 @@ export class FeatureTiles {
263272
* @return paint
264273
*/
265274
getLinePaint(featureStyle: FeatureStyle): Paint {
275+
if (this._overrideGeoPackageLinePaint) {
276+
return this.linePaint;
277+
}
266278
let paint = this.getFeatureStylePaint(featureStyle, FeatureDrawType.STROKE);
267279
if (paint === null) {
268280
paint = this.linePaint;
@@ -275,6 +287,9 @@ export class FeatureTiles {
275287
* @return paint
276288
*/
277289
getPolygonPaint(featureStyle: FeatureStyle): Paint {
290+
if (this._overrideGeoPackagePolygonPaint) {
291+
return this.polygonPaint;
292+
}
278293
let paint = this.getFeatureStylePaint(featureStyle, FeatureDrawType.STROKE);
279294
if (paint == null) {
280295
paint = this.polygonPaint;
@@ -288,6 +303,9 @@ export class FeatureTiles {
288303
* @return paint
289304
*/
290305
getPolygonFillPaint(featureStyle: FeatureStyle): Paint {
306+
if (this._overrideGeoPackagePolygonFillPaint && this.fillPolygon) {
307+
return this.polygonFillPaint;
308+
}
291309
let paint = null;
292310
let hasStyleColor = false;
293311
if (featureStyle != null) {
@@ -368,6 +386,11 @@ export class FeatureTiles {
368386
* @param {String} pointColor point color
369387
*/
370388
set pointColor(pointColor: string) {
389+
if (pointColor) {
390+
this._overrideGeoPackagePointPaint = true;
391+
} else {
392+
this._overrideGeoPackagePointPaint = false;
393+
}
371394
this.pointPaint.color = pointColor;
372395
}
373396
/**
@@ -382,6 +405,11 @@ export class FeatureTiles {
382405
* @param {Number} lineStrokeWidth line stroke width
383406
*/
384407
set lineStrokeWidth(lineStrokeWidth: number) {
408+
if (lineStrokeWidth) {
409+
this._overrideGeoPackageLineStrokeWidth = true;
410+
} else {
411+
this._overrideGeoPackageLineStrokeWidth = false;
412+
}
385413
this._lineStrokeWidth = lineStrokeWidth;
386414
this.linePaint.strokeWidth = this.scale * this.lineStrokeWidth;
387415
}
@@ -397,6 +425,11 @@ export class FeatureTiles {
397425
* @param {String} lineColor line color
398426
*/
399427
set lineColor(lineColor: string) {
428+
if (lineColor) {
429+
this._overrideGeoPackageLinePaint = true;
430+
} else {
431+
this._overrideGeoPackageLinePaint = false;
432+
}
400433
this.linePaint.color = lineColor;
401434
}
402435
/**
@@ -411,6 +444,11 @@ export class FeatureTiles {
411444
* @param {Number} polygonStrokeWidth polygon stroke width
412445
*/
413446
set polygonStrokeWidth(polygonStrokeWidth: number) {
447+
if (polygonStrokeWidth) {
448+
this._overrideGeoPackageLineStrokeWidth = true;
449+
} else {
450+
this._overrideGeoPackageLineStrokeWidth = false;
451+
}
414452
this._polygonStrokeWidth = polygonStrokeWidth;
415453
this.polygonPaint.strokeWidth = this.scale * polygonStrokeWidth;
416454
}
@@ -426,6 +464,11 @@ export class FeatureTiles {
426464
* @param {String} polygonColor polygon color
427465
*/
428466
set polygonColor(polygonColor: string) {
467+
if (polygonColor) {
468+
this._overrideGeoPackagePolygonPaint = true;
469+
} else {
470+
this._overrideGeoPackagePolygonPaint = false;
471+
}
429472
this.polygonPaint.color = polygonColor;
430473
}
431474
/**
@@ -440,6 +483,11 @@ export class FeatureTiles {
440483
* @param {String} polygonFillColor polygon fill color
441484
*/
442485
set polygonFillColor(polygonFillColor: string) {
486+
if (polygonFillColor) {
487+
this._overrideGeoPackagePolygonFillPaint = true;
488+
} else {
489+
this._overrideGeoPackagePolygonFillPaint = false;
490+
}
443491
this.polygonFillPaint.color = polygonFillColor;
444492
}
445493
getFeatureCountXYZ(x: number, y: number, z: number): number {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ngageoint/geopackage",
3-
"version": "3.0.6",
3+
"version": "3.0.7",
44
"description": "GeoPackage JavaScript Library",
55
"keywords": [
66
"NGA",

0 commit comments

Comments
 (0)