Hi Richard,

The postgis-users list might enjoy this challenge and have thoughts on performance considerations between table and views. I rarely use views so I won't comment.

I think you are right that postgis/postgres is failing on the extent() function because its being called on nothing, as mapnik is failing to find the geometry to use and instead of failing just trying on nothing.

If you build mapnik in debug mode you'll probably see mapnik output SQL that looks something like:

Select AsBinary() from all_roads where BBOX=....

while should be asBinary(geometry_column).

Two thoughts:

1) I think it would be excellent if mapnik PostGIS datasources would accept a keyword argument during __init__ or in the XML schema for the geometry_column (which would come in handy for this case and situations where you have more than one geometry column).

2) Short of that feature, try creating a new table (not a view) based on all roads and then add a geometry column record, this way mapnik should find it without a problem.

-- make sure you clear out any old ones...
DELETE FROM geometry_columns where f_table_name like 'all_roads';
INSERT INTO geometry_columns Select '', 'public', 'all_roads', 'GEOMETRY_FIELD_NAME', 2, SRID,'MULTILINESTRING';

-- then build your indexes

CREATE INDEX "idx_all_roads" ON "all_roads" USING GIST ( "geometry" GIST_GEOMETRY_OPS );
ALTER TABLE all_roads ALTER COLUMN GEOMETRY_FIELD_NAME SET NOT NULL;
CLUSTER idx_all_roads ON all_roads;
VACUUM ANALYZE all_roads;

Think that will help?

Dane


On Aug 18, 2008, at 9:40 AM, Richard Duivenvoorde wrote:

Hi List,

I've this big set of shp-files per country.
I've imported every shp-file per country in a table (so for every
country I've a table 'roads' etc etc).

Then I tried to make a view over all countries with something like:

create or replace view all_roads as
select * from nld_roads
union all
select * from lux_roads
union all
select * from bel_roads

Not sure if this is efficient, but anyway...
If I try to render nld_roads with a given mapnik-config all is fine.
But when I try to render all_roads (that is using the VIEW as
datasource) I see error messages in my postgis-log:

2008-08-18 18:19:50 CEST ERROR:  function extent() does not exist at
character 61
2008-08-18 18:19:50 CEST HINT:  No function matches the given name and
argument types. You may need to add explicit type casts.
2008-08-18 18:19:50 CEST STATEMENT:  select
xmin(ext),ymin(ext),xmax(ext),ymax(ext) from (select extent() as ext
from all_roads) as tmp

And looking in the postgis-plugin src I see:

std::string table_name=table_from_sql(table_);
std::ostringstream s;
s << "select f_geometry_column,srid,type from ";
s << GEOMETRY_COLUMNS <<" where f_table_name='" << table_name<<"'";

so apparently stuff went wrong because the geometry-column in the VIEW
is not registred as a geometry-column in the table 'geometry_columns'.

Now, normally you don't register a geometry column in a view again for a
view.
So my question: should/can I (re)register the geometry-column (again)
for the view (over my tables)?
Or is there another way to be able to aggragate stuff over several
tables instead of using a view?
Or am I on the wrong track anyway ...

Thanks in advance & regards,

Richard Duivenvoorde



_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to