Table of Contents

Property DefaultSrid

Namespace
YndigoBlue.Velocity.Data
Assembly
YndigoBlue.Velocity.dll

DefaultSrid

Gets or sets the default Spatial Reference System Identifier (SRID) applied to Geography columns.

public int DefaultSrid { get; set; }

Property Value

int

Remarks

This property only applies to the Geography data type (DataType.Geography). It has no effect on Geometry columns, which use planar coordinates with SRID 0 or a custom SRID set directly on the geometry object.

The SRID identifies the coordinate reference system for geography data — how latitude/longitude values map to real-world positions on Earth. The default value of 4326 represents WGS84, the coordinate system used by GPS and most mapping applications.

Measurement Units with Geography:

When performing distance, area, length, or buffer calculations on Geography columns, always specify the unit using the UnitOfMeasure enum rather than relying on raw numeric results. Without a unit, results are returned in the native unit of the coordinate system (degrees for WGS84), which is rarely what you want for real-world distance calculations.

  • Correct: new SpatialDistance(col, point, UnitOfMeasure.Kilometer) — returns distance in kilometers regardless of SRID.
  • Avoid: Raw distance results without a unit — returns values in the SRID's native unit (e.g., degrees for 4326), which are not meaningful as real-world distances.
warning

The DefaultSrid must match the SRID used when creating Geography columns in the database. A mismatch between this setting and the actual column SRID will cause spatial queries to produce incorrect results or fail entirely. Additionally, changing DefaultSrid after data has been stored will have a negative effect on already stored data and may cause serious issues: all spatial queries will misinterpret existing coordinates, distance calculations will be wrong, and spatial indexes may fail to work correctly. Set DefaultSrid correctly before storing any Geography data and avoid changing it afterward.

Common SRIDs:

  • 4326 — WGS84 (GPS, latitude/longitude in degrees). Default for most applications.
  • 3857 — Web Mercator (Google Maps, OpenStreetMap). Coordinates in meters.
Using UnitOfMeasure with a Geography distance query:
var conn = new SqlServerDatasourceConnection
{
    Hostname = "server.example.com",
    Database = "GeoData",
    Username = "user",
    Password = "password",
    DefaultSrid = 4326  // WGS84 — matches the Geography columns in this database
};

// Query rows within 10km of a point using UnitOfMeasure for meaningful results
var point = new Geography(new Point(-122.4194, 37.7749) { SRID = 4326 });
var query = new Query();
query.AddFromItem(table);
query.AddWhereItem(new SpatialDistance(table["location"], point, UnitOfMeasure.Kilometer), Operator.LessThan, 10);