Skip to main content
SQL keyword formatting
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

You can create a query to select all edges within some distance of the start and end points and then only the major roads in the bbox between the the start and end points. So something like:

selectSELECT * fromFROM edges whereWHERE st_dwithinST_DWithin(the_geom, start_pt, radius)
union
selectSELECT * fromFROM edges whereWHERE st_dwithinST_DWithin(the_geom, end_pt, radius)
union
selectSELECT * fromFROM edges whereWHERE st_expandST_Expand(st_setsridST_SetSRID(st_makelineST_MakeLine(start_pt, end_point), st_sridST_SRID(start_pt)), radius) && the_geom and road_class < 4;

As an alternative to the third select you could try:

selectSELECT * fromFROM edges whereWHERE st_dwithinST_DWithin(st_buffer(st_setsridST_SetSRID(st_makelineST_MakeLine(start_pt, end_point), st_sridST_SRID(start_pt)), radius) && the_geom and road_class < 4;

This will make a "sausage" of radius "radius" between the start and end and only select the segments the intersect with that sausage, you might need to increase the diameter by using something like 1.5radius or 3.0radius to make sure you are getting all the segments you need for the solution.

You can create a query to select all edges within some distance of the start and end points and then only the major roads in the bbox between the the start and end points. So something like:

select * from edges where st_dwithin(the_geom, start_pt, radius)
union
select * from edges where st_dwithin(the_geom, end_pt, radius)
union
select * from edges where st_expand(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

As an alternative to the third select you could try:

select * from edges where st_dwithin(st_buffer(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

This will make a "sausage" of radius "radius" between the start and end and only select the segments the intersect with that sausage, you might need to increase the diameter by using something like 1.5radius or 3.0radius to make sure you are getting all the segments you need for the solution.

You can create a query to select all edges within some distance of the start and end points and then only the major roads in the bbox between the the start and end points. So something like:

SELECT * FROM edges WHERE ST_DWithin(the_geom, start_pt, radius)
union
SELECT * FROM edges WHERE ST_DWithin(the_geom, end_pt, radius)
union
SELECT * FROM edges WHERE ST_Expand(ST_SetSRID(ST_MakeLine(start_pt, end_point), ST_SRID(start_pt)), radius) && the_geom and road_class < 4;

As an alternative to the third select you could try:

SELECT * FROM edges WHERE ST_DWithin(st_buffer(ST_SetSRID(ST_MakeLine(start_pt, end_point), ST_SRID(start_pt)), radius) && the_geom and road_class < 4;

This will make a "sausage" of radius "radius" between the start and end and only select the segments the intersect with that sausage, you might need to increase the diameter by using something like 1.5radius or 3.0radius to make sure you are getting all the segments you need for the solution.

You can create a query to select all edges within some distance of the start and end points and then only the major roads in the bbox between the the start and end points. So something like:

select * from edges where st_dwithin(the_geom, start_pt, radius) union select * from edges where st_dwithin(the_geom, end_pt, radius) union select * from edges where st_expand(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

select * from edges where st_dwithin(the_geom, start_pt, radius)
union
select * from edges where st_dwithin(the_geom, end_pt, radius)
union
select * from edges where st_expand(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

As an alternative to the third select you could try:

select * from edges where st_dwithin(st_buffer(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

select * from edges where st_dwithin(st_buffer(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

This will make a "sausage" of radius "radius" between the start and end and only select the segments the intersect with that sausage, you might need to increase the diameter by using something like 1.5radius or 3.0radius to make sure you are getting all the segments you need for the solution.

You can create a query to select all edges within some distance of the start and end points and then only the major roads in the bbox between the the start and end points. So something like:

select * from edges where st_dwithin(the_geom, start_pt, radius) union select * from edges where st_dwithin(the_geom, end_pt, radius) union select * from edges where st_expand(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

As an alternative to the third select you could try:

select * from edges where st_dwithin(st_buffer(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

This will make a "sausage" of radius "radius" between the start and end and only select the segments the intersect with that sausage, you might need to increase the diameter by using something like 1.5radius or 3.0radius to make sure you are getting all the segments you need for the solution.

You can create a query to select all edges within some distance of the start and end points and then only the major roads in the bbox between the the start and end points. So something like:

select * from edges where st_dwithin(the_geom, start_pt, radius)
union
select * from edges where st_dwithin(the_geom, end_pt, radius)
union
select * from edges where st_expand(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

As an alternative to the third select you could try:

select * from edges where st_dwithin(st_buffer(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

This will make a "sausage" of radius "radius" between the start and end and only select the segments the intersect with that sausage, you might need to increase the diameter by using something like 1.5radius or 3.0radius to make sure you are getting all the segments you need for the solution.

Source Link

You can create a query to select all edges within some distance of the start and end points and then only the major roads in the bbox between the the start and end points. So something like:

select * from edges where st_dwithin(the_geom, start_pt, radius) union select * from edges where st_dwithin(the_geom, end_pt, radius) union select * from edges where st_expand(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

As an alternative to the third select you could try:

select * from edges where st_dwithin(st_buffer(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4;

This will make a "sausage" of radius "radius" between the start and end and only select the segments the intersect with that sausage, you might need to increase the diameter by using something like 1.5radius or 3.0radius to make sure you are getting all the segments you need for the solution.