Opened 15 years ago

Closed 13 years ago

Last modified 13 years ago

#375 closed enhancement (fixed)

Add lwcollection_homogenize and ST_Homogenize

Reported by: colivier Owned by: pramsey
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version:
Keywords: homogenize collection ST_GeomFromKML Cc:

Description

/*
** Given a generic collection, return the "simplest" form.
**
** eg: GEOMETRYCOLLECTION(MULTILINESTRING()) => MULTELINESTRING()
**     GEOMETRYCOLLECTION(MULTILINESTRING(), MULTILINESTRING(), POINT())
**      => GEOMETRYCOLLECTION(MULTILINESTRING(), MULTIPOINT())
**
** In general, if the subcomponents are homogeneous, return a properly
** typed collection.
** Otherwise, return a generic collection, with the subtypes in minimal
** typed collections.

I need this stuff for ST_GeomFromKML, to be able to return simplest geometry forms if KML input is mixed.

Change History (13)

comment:1 by colivier, 15 years ago

Synopsys become:

/*
** Given a generic geometry, return the "simplest" form.
**
** eg: 
**     LINESTRING() => LINESTRING()
**
**     MULTILINESTRING(with a single line) => LINESTRING()
**
**     GEOMETRYCOLLECTION(MULTILINESTRING()) => MULTILINESTRING()
**
**     GEOMETRYCOLLECTION(MULTILINESTRING(), MULTILINESTRING(), POINT())
**      => GEOMETRYCOLLECTION(MULTILINESTRING(), POINT())
*/

Commited in lwgeom as r5265 and r5266

Do you think is worth to be exposed as SQL function also ? And if yes ST_Homogenize is a good name choice ?

comment:2 by colivier, 15 years ago

Resolution: fixed
Status: newclosed

If no one react, i guess that it doesn't worth that much to expose to SQL this function. ;)

I close the ticket.

comment:3 by pramsey, 13 years ago

Resolution: fixed
Status: closedreopened

comment:4 by pramsey, 13 years ago

Owner: changed from colivier to pramsey
Status: reopenednew

comment:5 by strk, 13 years ago

Reacting, as I like this function :) Olivier: still interested in bringing it in ?

comment:6 by colivier, 13 years ago

Sandro,

Core function is already in. just need to expose it trought PostGIS API.

Can took it, with an help on the related documentation.

comment:7 by robe, 13 years ago

Olivier,

If you provide PostGIS API I'll help you document it.

comment:8 by pramsey, 13 years ago

OK, I've updated the internal function to handle more types, now to do the SQL binding.

comment:9 by pramsey, 13 years ago

And the function is committed to trunk at r9009

comment:10 by pramsey, 13 years ago

Resolution: fixed
Status: newclosed

Docs committed at r9010

comment:11 by strk, 13 years ago

Why did this one end up being called ST_CollectionHomogenize rather than just ST_Homogenize ? It also homogenizes MULTI*, not just collection. Are we in time to rename before going final or should we live with the current name forever ?

comment:12 by strk, 13 years ago

Beside, documentation is also wrong: "Collections that are homogeneous will be returned as the appropriate multi-type", while instead a GEOMETRYCOLLECTION composed by a single element is returned as a point, not a multi-point. Or maybe that's what "singleton" was about..

in reply to:  11 comment:13 by pramsey, 13 years ago

Replying to strk:

Why did this one end up being called ST_CollectionHomogenize rather than just ST_Homogenize ? It also homogenizes MULTI*, not just collection.

It puts it next to ST_CollectionExtract it's similar-but-different functional cousin.

Note: See TracTickets for help on using tickets.