.NET API

RegisterPostGISDatabase

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

Parameters

Name Required Type Description
connectionString Yes String The connection-string to the database
options No Mapzania.Platform.PostGIS.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

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 PostGISl LayerSources
    var options = new Platform.PosGIS.ProviderOptions {
        Prefix = "MYDB_",
        DefaultSRID = "EPSG:4283"
    };
    
    // Register the PostGIS database
    Mapzania.Services.RegisterPostGisDatabase(connectionString, options);
    
    // Start Mapzania
    Mapzania.Services.Start(this);
    
    AreaRegistration.RegisterAllAreas();
    GlobalConfiguration.Configure(WebApiConfig.Register);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
    ...
}