.NET API

RegisterMsSqlSpatialDatabase

This method is used to register all spatial tables in an MSSQL Spatial database as layer-sources.

Parameters

Name Required Type Description
connectionString Yes String The connection-string to the database
options No Mapzania.Platform.MsSqlSpatial.ProviderOptions Options for registering the database.

Options

Name Default Type Description
Prefix String.Empty String This string is appended to the spatial table name to provide the layer-source key (which is always uppercase). For example if the spatial table in the database is named "AmericanRivers" and the prefix is set to "USA_" the layer-source key will be "USA_AMERICARIVERS"
DefaultSRID "LATLONG" String Sets the SRID of all layer-sources registered from the database
DefaultIdColumnName "Id" String Sets the id column name for all layer-sources registered from the database
DefaultGeometryColumnName "Geometry" String Sets the geometry column name for all layer-sources registered from the database

Example


void Application_Start(object sender, EventArgs e)
{
	...

    // Obtain a connectionstring from ConfigurationManager (web.config)
    var connectionString = ConfigurationManager.ConnectionStrings["MY_CONNECTION"].ConnectionString;
    
    // Set options for MSSQL Spatial LayerSources
    var options = new Platform.MsSqlSpatial.ProviderOptions {
        Prefix = "MYDB_",
        DefaultSRID = "EPSG:4283",
        DefaultIdColumnName = "MY_ID",
        DefaultGeometryColumnName = "MY_GEOMETRY"
    };
    
    // Register the MSSQl Spatial database
    Mapzania.Services.RegisterMsSqlSpatialDatabase(connectionString, options);
    
    // Start Mapzania
    Mapzania.Services.Start(this);
    
    AreaRegistration.RegisterAllAreas();
    GlobalConfiguration.Configure(WebApiConfig.Register);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
    ...
}