Opened 6 years ago

Closed 4 years ago

Last modified 3 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 Changed 6 years ago by colivier

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 Changed 6 years ago by colivier

  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 4 years ago by pramsey

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:4 Changed 4 years ago by pramsey

  • Owner changed from colivier to pramsey
  • Status changed from reopened to new

comment:5 Changed 4 years ago by strk

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

comment:6 Changed 4 years ago by colivier

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 Changed 4 years ago by robe

Olivier,

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

comment:8 Changed 4 years ago by pramsey

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

comment:9 Changed 4 years ago by pramsey

And the function is committed to trunk at r9009

comment:10 Changed 4 years ago by pramsey

  • Resolution set to fixed
  • Status changed from new to closed

Docs committed at r9010

comment:11 follow-up: Changed 3 years ago by strk

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 Changed 3 years ago by strk

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..

comment:13 in reply to: ↑ 11 Changed 3 years ago by pramsey

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.