Hi Alexandre,
> QGIS do it with no problems with shapefiles, but gives some fight
> with
> SpatiaLite.
>
please note: the ESRI Shapefile format is really ancient, and was
invented well before any international standard specification
about Geometry.
so SHP doesn't make any difference between Linestrings and
MultiLinestrings, and the same is for Polygons and MultiPolygons;
but curiously enough, Points and MultiPoints are two completely
different things for SHP :-)
SpatiaLite (as many others Spatial DBMSes) makes a strong distinction
between Points and MultiPoints, Linestrings and MultiLinestrings,
Polygons and MultiPolygons; it's not at all an odd invention of our
own,
it's a strictly required design feature so to be standard compliant.
> As I see it, the problem lies in trying to copy POLYGON features to a
> MULTIPOLYGON tables. Even importing the shapefile to Spatialite
> (using
> Spatialite-GUI) , unless you have at least one multipolygon feature,
> your table geometry will be set to the POLYGON type. And of course
> trying to copypaste feature from it will give the same error.
>
if verified, this looks like a QGIS own failure; you can never insert
a MultiPolygon geometry (containing more elementary Polygons) into a
Polygon table (for obvious reasons).
but there is no real reason forbidding to insert a simple Polygon into
a
MultiPolygon table ... the sw agent is simply required to apply the
appropriate
type casting (promoting the Polygon to MultiPolygon), and that's all.
Just for my personal curiosity: have you ever tried the same operation
on behalf of PostGIS ? what happens in this second case ?
a) if the behavior is the same for PostGIS and SpatiaLite, than it
would
be obviously mean that QGIS has some idiosyncrasy.
b) if PostGIS and SpatiaLite behave differently, this could probably
mean
that the spatialite own data-provider has some problem requiring to
be fixed someway.
> My workaround is add a multipolygon feature to the shapefile before
> import it to SpatiaLite.
>
there is a (may be) simpler way allowing to get exactly the same
result:
a) import your shapefile, and check if it's of the Polygon type.
b) if yes, you can easily promote it to the MultiPolygon type by
immediately executing these (really tricky) SQL statements:
UPDATE geometry_columns SET type = 'MULTIPOLYGON'
WHERE f_table_name = 'my_table';
UPDATE my_table SET Geometry = CastToMultiPolygon(Geometry);
> My question is, is there a way to change the triggers so that if the
> table is a MULTIPOLYGON type, it will accept also POLYGON Geometries?
> will that affect the rest of the Spatialite database?
>
it's not a technical problem; if you carefully examine the internal
binary representation, you'll soon discover that a Polygon and a
MultiPolygon containing a single elementary Polygon are quite exactly
the same.
but they actually belong to two completely different Geometry Classes,
and the OGC-SFS standard strictly requires to consider the one and the
other as very different objects.
it's mainly a standard compliance question; by applying a patch like
this one we'll automatically break any standard requirement.
... and this doesn't look wise at all ;-)
bye Sandro
--
Il messaggio e' stato analizzato alla ricerca di virus o
contenuti pericolosi da MailScanner, ed e'
risultato non infetto.