[mapguide-users] Help with Spatial Contexts
Bernhard Maehler
bernhard.maehler at gmx.de
Fri Mar 10 12:10:52 PST 2017
I am using PostgreSQL 9.6.2 with PostGIS 2.3.2 and AIMS 2017.
As Jackie has mentioned before, I can confirm that the PostgreSQL Provider
uses the f_scinfo table to obtain the name of the spatial context.
However this table has no data and it is not necessary to create it as it
only provides the names for the spatial context.
Further explanations (example):
Your PostgreGIS database has three tables: table_a, table_b and table_c.
Each table has a different spatial context (EPSG code):
- table_a uses EPSG code 3400 -- NAD83 / Alberta 10-TM (Forest)
- table_b uses EPSG code 4269 -- NAD83
- table_c uses EPSG code 4326 -- WGS 84
Once you have crated a new feature source (= data source or connection to
your PostGIS database with Maestro) the spatial contexts are named like sc_1
(for EPSG:3400), sc_2 (for EPSG:4269), sc_3 (for EPSG:4326).
Once you have created your layers from your new data source (e. g. layer_a
for table_a, layer_b for table_b, layer_c for table_c) the assigned spatial
contexts for the layers are:
- sc_1 for layer_a (= EPSG:3400)
- sc_2 for layer_b (= EPSG:4269)
- sc_3 for layer_c (= EPSG:4326)
So each layer uses its own spatial context which is automatically assigned
by your feature source.
To come back to your question:
Should I always have a separate data source for every layer?
- No
Should I have a separate data source for every Spatial Context in a
database?
- No
How does a layer get assigned a Spatial Context?
- From the spatial context of the assigned PostGIS table or the view
public.geometry_columns
Can I specify what Spatial Context a layer should use?
- Not directly, with Maestro you can overwrite the spatial context of your
data source but this affects all layers that use the same spatial context. A
better way is to transform the spatial context of your table (layer) with
PostGIS functions.
If you want clear names for your spatial context, you can use the following
SQL script to create the table f_scinfo.
The PostgreSQL Provider obtains the names of the spatial context from the
columns of this table, so instead of "sc_1" the name will be "EPSG_3400".
For each spatial context (EPSG code) of your database you have to create a
new column.
-- Table: public.f_scinfo
-- DROP TABLE public.f_scinfo;
CREATE TABLE public.f_scinfo
(
f_scinfo_id bigint NOT NULL,
"EPSG_3400" geometry(Geometry,3400),
"EPSG_4269" geometry(Geometry,4269),
"EPSG_4326" geometry(Geometry,4326),
CONSTRAINT pk_f_scinfo PRIMARY KEY (f_scinfo_id)
)
WITH (
OIDS=FALSE
);
-- Spatial index: public.f_scinfo_epsg_3400_si
-- DROP INDEX public.f_scinfo_epsg_3400_si;
CREATE INDEX f_scinfo_epsg_3400_si
ON public.f_scinfo
USING gist
("EPSG_3400");
-- Spatial index: public.f_scinfo_epsg_4326_si
-- DROP INDEX public.f_scinfo_epsg_4326_si;
CREATE INDEX f_scinfo_epsg_4269_si
ON public.f_scinfo
USING gist
("EPSG_4269");
-- Spatial index: public.f_scinfo_epsg_4326_si
-- DROP INDEX public.f_scinfo_epsg_4326_si;
CREATE INDEX f_scinfo_epsg_4326_si
ON public.f_scinfo
USING gist
("EPSG_4326");
Output in Maestro:
<http://osgeo-org.1560.x6.nabble.com/file/n5311809/2017-03-10_12_45_26-MapGuide_Maestro.jpg>
- Bernhard
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Help-with-Spatial-Contexts-tp5310988p5311809.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list