find overlapping address ranges - Mailing list pgsql-general

From Alex Rice
Subject find overlapping address ranges
Date
Msg-id 875D94C0-C9A9-11D6-9B03-000393529642@arc.to
Whole thread Raw
Responses Re: find overlapping address ranges  (Tino Wildenhain <tino@wildenhain.de>)
List pgsql-general
This is more of a SQL question than a pgsql question. I know this
should not be hard, I just can't wrap my mind around it. Thanks...

So I have a table with street names and address ranges. Some of the
address ranges overlap for the same street ranges, and I need to write
a report on those rows. In other words, I want to do something similar
to this:

SELECT gid, street, fromleft, toleft, fromright, toright
FROm cityplus WHERE
HAS_OVERLAPPING_ADDRESS_RANGE_FOR_SAME_STREETNAME()
ORDER BY street

Does this require a subselect? Stored procedure? Neither? Can I use a
pgsql line geometric type to check for overlap? This data is in Postgis
as well, so I have those methods at my disposal as well.


               Table "cityplus"
    Column   |       Type        | Modifiers
------------+-------------------+-----------
  gid        | integer           |
  street     | character varying |
  fromleft   | integer           |
  toleft     | integer           |
  fromright  | integer           |
  toright    | integer           |
  fnode_     | integer           |
  tnode_     | integer           |
  lpoly_     | integer           |
  rpoly_     | integer           |
  length     | double precision  |
  netcurr_   | integer           |
  netcurr_id | integer           |
  l_low      | integer           |
  l_high     | integer           |
  r_low      | integer           |
  r_high     | integer           |
  str        | character varying |
  dgn        | character varying |
  q          | character varying |
  stanno     | character varying |
  code       | integer           |
  the_geom   | geometry          |
Indexes: cityplus_addnum_index,
          cityplus_geom_index,
          cityplus_gid_index,
          cityplus_oid_index
Check constraints: "$1" (srid(the_geom) = -1)
                    "$2" ((geometrytype(the_geom) =
'MULTILINESTRING'::text) OR (
the_geom IS NULL))


Alex Rice
Mindlube Software
http://mindlube.com/


pgsql-general by date:

Previous
From: Cindy
Date:
Subject: question regarding regular expressions
Next
From: Manfred Koizar
Date:
Subject: Re: Physical sites handling large data