2

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 got to do some further digging but would appreciate any insights people have. 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..

Update: Sorry, I forgot to mention that 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.

  • 1
    Did you check "mapinfo"."mapinfo_mapcatalog" table ? – sys49152 Feb 16 '14 at 13:27
  • sys49152 is correct, the Easyloader "process" also adds a row to the MapInfo.Mapcatalog table, ogr2ogr does not. This is essential for MapInfo to read ODBC data. – Morgan Ellingham Feb 16 '14 at 22:40
  • Sorry, I forgot to mention I've built the mapinfo.mapinfo_mapcatalog. – AndyB Feb 17 '14 at 8:40
  • Could it be that you are using PostGIS 2.0 and a version of MapInfo Professional previous to v12.0? MapInfo Professional only supports PostGIS 2.0 from v12.0. There are some workarounds for making older versions of MapInfo Professional support PostGIS 2.0 which include creating views/tables that were removed between PostGIS 1.5 and PostGIs 2.0 – Peter Horsbøll Møller Feb 18 '14 at 9:07
  • Thanks Peter, yes I should have mentioned I'm using PostGIS 1.5. You wouldn't have details of suitable workarounds would you? – AndyB Feb 24 '14 at 8:47
5

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

  • Hi Peter, i forgot to mention that I have created a mapinfo_mapcatalog table and inserts to that are triggered by inserts to geometry_columns. It's good to hear that I can use other tools aside from EasyLoader as we're primarily ogr ppl. – AndyB Feb 17 '14 at 12:21
  • Sorry - my comment wasn't particularly clear. I had already created the mapinfo_mapcatalog table before I hit the error. – AndyB Feb 18 '14 at 11:14
  • @AndyB, did you see my comment under your question? It might the version of PostGIS?! – Peter Horsbøll Møller Feb 18 '14 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.