• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ngageoint / geopackage-js / 4078143969

pending completion
4078143969

push

github

Christopher Caldwell
bump version

3593 of 8015 branches covered (44.83%)

Branch coverage included in aggregate %.

15102 of 20471 relevant lines covered (73.77%)

1564.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.69
/lib/features/user/featureTable.ts
1
import { UserTable } from '../../user/userTable';
1✔
2
import { FeatureColumn } from './featureColumn';
3
import { FeatureColumns } from './featureColumns';
1✔
4
import { Contents } from '../../contents/contents';
5
import { ContentsDataType } from '../../contents/contentsDataType';
1✔
6
import { GeometryColumns } from '../columns/geometryColumns';
1✔
7
import { GeoPackageException } from '../../geoPackageException';
1✔
8

9
/**
10
 * Represents a user feature table
11
 * @param  {string} tableName table name
12
 * @param  {array} columns   feature columns
13
 */
14
export class FeatureTable extends UserTable<FeatureColumn> {
1✔
15
  /**
16
   * Constructor
17
   * @param geometryColumns geometry columns
18
   * @param columns  feature columns
19
   */
20
  public constructor(geometryColumns: GeometryColumns, columns: FeatureColumn[]);
21

22
  /**
23
   * Constructor
24
   * @param tableName table name
25
   * @param columns feature columns
26
   */
27
  public constructor(tableName: string, columns: FeatureColumn[]);
28

29
  /**
30
   * Constructor
31
   * @param tableName table name
32
   * @param geometryColumn geometry column
33
   * @param columns feature columns
34
   */
35
  public constructor(tableName: string, geometryColumn: string, columns: FeatureColumn[]);
36

37
  /**
38
   * Copy Constructor
39
   * @param featureTable feature table
40
   */
41
  public constructor(featureTable: FeatureTable);
42

43
  /**
44
   * Constructor
45
   * @param args
46
   */
47
  public constructor(...args) {
1,940✔
48
    if (args.length === 1) {
388!
49
      super(args[0]);
×
50
    } else if (args.length === 2) {
388!
51
      if (args[0] instanceof GeometryColumns) {
×
52
        const geometryColumn = args[0];
×
53
        const columns: FeatureColumn[] = args[1];
×
54
        super(new FeatureColumns(geometryColumn.getTableName(), geometryColumn.getColumnName(), columns, false));
×
55
      } else if (typeof args[0] === 'string') {
×
56
        const tableName = args[0];
×
57
        const columns: FeatureColumn[] = args[1];
×
58
        super(new FeatureColumns(tableName, undefined, columns, false));
×
59
      }
60
    } else if (args.length === 3) {
388!
61
      const tableName = args[0];
388✔
62
      const geometryColumn = args[1];
388✔
63
      const columns: FeatureColumn[] = args[2];
388✔
64
      super(new FeatureColumns(tableName, geometryColumn, columns, false));
388✔
65
    }
66
  }
67

68
  copy(): FeatureTable {
1✔
69
    return new FeatureTable(this.getTableName(), this.getGeometryColumnName(), this.getUserColumns().getColumns());
2✔
70
  }
71

72
  /**
73
   * @inheritDoc
74
   */
75
  public getDataType(): string {
1✔
76
    return this.getDataTypeOrDefault(ContentsDataType.nameFromType(ContentsDataType.FEATURES));
1✔
77
  }
78

79
  /**
80
   * @inheritDoc
81
   */
82
  public getUserColumns(): FeatureColumns {
1✔
83
    return super.getUserColumns() as FeatureColumns;
7,411✔
84
  }
85

86
  /**
87
   * @inheritDoc
88
   */
89
  public createUserColumns(columns: FeatureColumn[]): FeatureColumns {
1✔
90
    return new FeatureColumns(this.getTableName(), this.getGeometryColumnName(), columns, true);
371✔
91
  }
92

93
  /**
94
   * Get the geometry column index
95
   * @return geometry column index
96
   */
97
  getGeometryColumnIndex(): number {
1✔
98
    return this.getUserColumns().getGeometryIndex();
×
99
  }
100

101
  /**
102
   * Get the geometry feature column
103
   * @return geometry feature column
104
   */
105
  getGeometryColumn(): FeatureColumn {
1✔
106
    return this.getUserColumns().getGeometryColumn();
4,647✔
107
  }
108

109
  /**
110
   * Get the geometry column name
111
   * @return geometry column name
112
   */
113
  getGeometryColumnName(): string {
1✔
114
    return this.getUserColumns().getGeometryColumnName();
884✔
115
  }
116

117
  /**
118
   * Get the Id and Geometry Column names
119
   * @return column names
120
   */
121
  getIdAndGeometryColumnNames(): string[] {
1✔
122
    return [this.getPkColumnName(), this.getGeometryColumnName()];
26✔
123
  }
124

125
  /**
126
   * @inheritDoc
127
   */
128
  validateContents(contents: Contents): void {
1✔
129
    // Verify the Contents have a features data type
130
    const dataType = contents.getDataType();
380✔
131
    if (dataType === null || dataType === undefined || dataType !== ContentsDataType.FEATURES) {
380!
132
      throw new GeoPackageException(
×
133
        'The Contents of a FeatureTable must have a data type of ' + ContentsDataType.FEATURES,
134
      );
135
    }
136
  }
137
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc