Monday, 19 August 2019

Will MapInfo only read PostGIS data that has been loaded via EasyLoader?


NMZ says in this thread that MapInfo will only read data in PostGIS that has been loaded by MapInfo's EasyLoader. I wasn't sure if this was still the case so I've loaded data into postgis via ogr2ogr but indeed MapInfo 12 hits a problem:



ODBC Error: ODBC RC=-1, ODBC SQLState=42601, DBMS RC=7, DBMS Msg=ERROR: zero-length delimited identifier at or near """"; Error while executing the query.

In the postgresql log I can see MapInfo attempting to execute a select statement;


2014-02-16 10:36:36 UTC ERROR:  zero-length delimited identifier at or near """" at character 74
2014-02-16 10:36:36 UTC STATEMENT: select "ogc_fid", "app_ref", "id", "sdw"."planning"."polygons_ogr_28777"."", public.ST_AsBinary("wkb_geometry") as "wkb_geometry" from "sdw"."planning"."polygons_ogr_28777"

That ."" on the polygons table looks pretty weird to me. Taking a look at the query MapInfo is asking of PostGIS on an easyloader table looks like this;


2014-02-16 10:36:21 UTC LOG:  statement: select "app_ref", "id", "MI_PRINX", "MI_STYLE", public.ST_AsBinary("SP_GEOMETRY") as "SP_GEOMETRY" from "sdw"."planning"."polygons_bng5365"

No ."" in this one.



I'm wondering if MapInfo is particularly to MI_PRINX being the primary key. I've pasted the fuller log file here - loading the two tables via ogr (polygons_ogr_28777) and easyloader (polygons_bng5365) and then accessing the pair via MapInfo.


The numbers in the table names do not reflect any srid btw. Just numbers..


I've built a mapinfo.mapinfo_mapcatalog. There's a trigger function which populates this table when an insert is made to geometry_columns. (PG1.5). The entries for the two tables are;


"spatialtype";"tablename";"ownername";"spatialcolumn"
;"db_x_ll";"db_y_ll";"db_x_ur";"db_y_ur"
;"view_x_ll";"view_y_ll";"view_x_ur";"view_y_ur"
;"coordinatesystem"
;"symbol"
;"xcolumnname";"ycolumnname"
;"renditiontype";"renditioncolumn";"renditiontable";"number_rows"


19.2;"polygons_bng5365";"planning";"SP_GEOMETRY"
;487932.174983;162961.282073;487976.574637;163000.880738
;487932.174983;160574.96515;490597.036446;163000.880738
;"Earth Projection 8, 79, ""m"", -2, 49, 0.9996012717, 400000, -100000 Bounds (-7845061.1011, -15524202.1641) (8645061.1011, 4470074.53373)"
;""
;"NO_COLUMN";"NO_COLUMN"
;1;"MI_STYLE";"";

19.3;"polygons_ogr_28777";"planning";"wkb_geometry"

;0;0;700000;1300000
;0;0;700000;1300000
;"Earth Projection 8, 79, ""m"", -2, 49, 0.9996012717, 400000, -100000 Bounds (-7845061.1011, -15524202.1641) (8645061.1011, 4470074.53373)"
;"SYMBOL (35,0,12) PEN (1,2,0) BRUSH (2,16777215,16777215) "
;"NO_COLUMN";"NO_COLUMN"
;1;"";"";

The mapinfo.mapinfo_mapcatalog definition is as follows;


-- DROP TABLE mapinfo.mapinfo_mapcatalog;


CREATE TABLE mapinfo.mapinfo_mapcatalog
(
spatialtype double precision,
tablename character varying(32),
ownername character varying(32),
spatialcolumn character varying(32),
db_x_ll double precision,
db_y_ll double precision,
db_x_ur double precision,
db_y_ur double precision,

view_x_ll double precision,
view_y_ll double precision,
view_x_ur double precision,
view_y_ur double precision,
coordinatesystem character varying(254),
symbol character varying(254),
xcolumnname character varying(32),
ycolumnname character varying(32),
renditiontype integer,
renditioncolumn character varying(32),

renditiontable character varying(32),
number_rows integer
)
WITH (
OIDS=FALSE
);
ALTER TABLE mapinfo.mapinfo_mapcatalog OWNER TO postgres;
GRANT ALL ON TABLE mapinfo.mapinfo_mapcatalog TO postgres;
GRANT ALL ON TABLE mapinfo.mapinfo_mapcatalog TO public;


-- Index: mapinfo.mapcatalog_idx

-- DROP INDEX mapinfo.mapcatalog_idx;

CREATE UNIQUE INDEX mapcatalog_idx
ON mapinfo.mapinfo_mapcatalog
USING btree
(tablename, ownername);

The MapInfo manual also says to create a MapInfo user account which I have done though not sure of its worth.




Answer



As it already has been mentioned in comments to your questions, MapInfo Professional does require the table to be added to the MapInfo.MapInfo_MapCatalog.


This table tells MapInfo Professional how to handle and display the spatial part of the table.


You do however not need to use EasyLoader to load your table - you can do it with other tools, too. But you need to populate the MapInfo.MapInfo_MapCatalog table with values for each of the spatial tables that you want to open in MapInfo Professional. EasyLoader will do this for you.


Some steps to have in mind when you want to access a spatial database from MapInfo Professional:


For every database:



  • Create the MapInfo.MapInfo_MapCatalog. EasyLoader can help you with this step


For every spatial table:




  • Add information about the spatial table to the MapInfo.MapInfo_MapCatalog. You can do this via the menu item Table > Maintenance > Make DBMS Table Mappable in MapInfo Professional, or you can, if you know what you are doing, do it "manually"


If you want to read more about wotking with MapInfo Professional and spatial databases, have a look at this prensentation on slideshare: - MapInfo Professional 11.0 and SQL Server 2008


It's based on SQL Server 2008 but the basics will be the same for Oracle and PostGIS, too.


The presentation also takes you thru the MapCatalog


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...