Extension Title

Feature Style

Introduction

This extension defines styles and icons for feature geometries. Feature tables may assigned default styles and features may be individually styled. Styles may be assigned as geometry type specific.

This extension depends on the OGC GeoPackage Related Tables Extension.

This extension depends on the NGA Contents Id Extension for default style configurations.

Extension Author

National Geospatial-Intelligence Agency, author_name nga

Extension Name or Template

nga_feature_style

Extension Type

New Requirement

Applicability

This extension applies to the table names of feature user tables (2.1.6).

Scope

Read-write

Requirements

GeoPackage

Feature Style
Extension Table Entries

The Feature Style extension is registered into the gpkg_extensions table once per feature table. Each user-defined mapping table between a feature or table and a style or icon is registered per the Related Tables Extension.

<feature_table_name> = name of a feature table

gpkg_extensions entries
table_name column_name extension_name definition scope

<feature_table_name>

null

nga_feature_style

URL to this extension description

read-write

nga_style_<feature_table_name>

null

related_tables

http://www.geopackage.org/18-000.html

read-write

nga_icon_<feature_table_name>

null

related_tables

http://www.geopackage.org/18-000.html

read-write

nga_style_default_<feature_table_name>

null

related_tables

http://www.geopackage.org/18-000.html

read-write

nga_icon_default_<feature_table_name>

null

related_tables

http://www.geopackage.org/18-000.html

read-write

Contents Entries

The Feature Style extension nga_style and nga_icon tables are listed as attribute contents tables alongside feature tables.

gpkg_contents entries
table_name data_type identifier description last_change min_x min_y max_x max_y srs_id

<feature_table_name>

features

any

any

any

any

any

any

any

any

nga_style

attributes

any

any

any

null

null

null

null

null

nga_icon

attributes

any

any

any

null

null

null

null

null

Style Table

The Style Table defines a geometry style and is an Attributes Table.

nga_style
Column Name Type Description Null Default Key

id

INTEGER

Autoincrement primary key

no

PK

name

TEXT

Feature Style name

yes

description

TEXT

Feature Style description

yes

color

TEXT

Geometry color in hex format #RRGGBB or #RGB, when null assume #000000

yes

opacity

REAL

Geometry color opacity inclusively between 0.0 and 1.0, when null assume 1.0

yes

width

REAL

Geometry line stroke or point width >= 0.0, when null assume 1.0

yes

fill_color

TEXT

Closed geometry fill color in hex format #RRGGBB or #RGB, no fill when null

yes

fill_opacity

REAL

Closed geometry fill color opacity inclusively between 0.0 and 1.0, when null assume 1.0

yes


CREATE TABLE nga_style (
  id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  name TEXT,
  description TEXT,
  color TEXT,
  opacity REAL,
  width REAL,
  fill_color TEXT,
  fill_opacity REAL
);
Icon Table

The Icon Table defines a geometry icon or marker and is a Related Tables Extension Media Table.

nga_icon
Column Name Type Description Null Default Key

id

INTEGER

Autoincrement primary key

no

PK

data

BLOB

Feature Icon content

no

content_type

TEXT

Mime-type of the feature icon

no

name

TEXT

Feature Icon name

yes

description

TEXT

Feature Icon description

yes

width

REAL

Icon display width. When null and height has value, maintain aspect ratio. When null and height is null, use data icon width.

yes

height

REAL

Icon display height. When null and width has value, maintain aspect ratio. When null and width is null, use data icon height.

yes

anchor_u

REAL

UV Mapping horizontal anchor distance inclusively between 0.0 and 1.0 from the left edge, when null assume 0.5 (middle of icon)

yes

anchor_v

REAL

UV Mapping vertical anchor distance inclusively between 0.0 and 1.0 from the top edge, when null assume 1.0 (bottom of icon)

yes


CREATE TABLE nga_icon (
  id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  data BLOB NOT NULL,
  content_type TEXT NOT NULL,
  name TEXT,
  description TEXT,
  width REAL,
  height REAL,
  anchor_u REAL,
  anchor_v REAL
);
Contents Id

The Contents Id Extension is used to relate default styles to a feature table by an INTEGER primary key, as required by the Related Tables Extension User-Defined Mapping Tables.

nga_contents_id entries
id table_name

any

<feature_table_name>

Mapping Tables

Related Tables Extension Mapping Tables are used to relate:

The Mapping Tables are defined in the Related Tables Extension Relations Table:

gpkgext_relations entries
id base_table_name base_primary_column related_table_name related_primary_column relation_name mapping_table_name

any

nga_contents_id

id

nga_style

id

attributes

nga_style_default_<feature_table_name>

any

nga_contents_id

id

nga_icon

id

media

nga_icon_default_<feature_table_name>

any

<feature_table_name>

id

nga_style

id

attributes

nga_style_<feature_table_name>

any

<feature_table_name>

id

nga_icon

id

media

nga_icon_<feature_table_name>

Style and Icon Mapping Tables contain the id mapping columns and a nullable geometry_type_name.

nga_style_default_<feature_table_name>, nga_icon_default_<feature_table_name>, nga_style_<feature_table_name>, nga_icon_<feature_table_name>
Column Name Type Description Null Default Key

base_id

INTEGER

The primary key value of the base data table (nga_contents_id or <feature_table_name>)

no

related_id

INTEGER

The primary key value of the related data table (nga_style or nga_icon)

no

geometry_type_name

TEXT

Name from Geometry Type Codes (Core) or Geometry Type Codes (Extension) in Geometry Types (Normative)

A null value configures a top level or default geometry style or icon.

A defined geometry type maps the style or icon for geometries of that and inherited geometry types. The lowest configured feature matching geometry type takes priority.

User-Defined Mapping Table unique constraints are discouraged, but duplicate base_id, related_id, and geometry_type_name triplets are discouraged as conflicting styling may be unpredictable.

yes


CREATE TABLE nga_[style_default|icon_default|style|icon]_<feature_table_name> (
  base_id INTEGER NOT NULL,
  related_id INTEGER NOT NULL,
  geometry_type_name TEXT
);

GeoPackage SQLite Configuration

None

GeoPackage SQLite Extension

None

Examples

The rivers GeoPackage has a default style for the rivers feature table.

The example GeoPackage has styles and icons for the geometry1 and geometry2 feature tables.