|
Geometry : |
From: Matthieu Beghin (matt.beghin_at_[hidden])
Date: 2019-09-20 09:59:11
Hi,
You should create your own algorithm. For instance, in non-optimal and not
well written pseudo c++:
void mergeLineStrings(std::vector<line_string>& in,
std::vector<line_string>& out, double threshlod) {
// Process first item of "in"
auto toProcess = in.front(); // This copy should be avoided
in.erase(in.begin()); // So remove it from container
for (auto outIt=out.begin(); outIt!=out.end(); outIt++) {
// see if first point of toProcess and first point of outIt are close
enough to merge
if (distance(toProcess.begin(), outIt->begin()) < threshold) {
// insert points from toProcess at the beginning of outIt
...
return;
}
// see if first point of toProcess and last point of outIt are close
enough to merge
...
// see if last point of toProcess and first point of outIt are close
enough to merge
...
// see if last point of toProcess and last point of outIt are close
enough to merge
...
}
// Found no out line_string to merge with, add toProcess in out
line_strings
out.push_back(toProcess);
}
// Processing would be
std::vector<line_string> in = {{....}};
std::vector<line_string> out;
while (!in.empty()) {
mergeLineStrings(in,out, threshold);
}
Hope that helps.
Cheers
Matthieu Beghin
On Fri, Sep 20, 2019 at 8:59 AM Ahmet Temiz via Geometry <
geometry_at_[hidden]> wrote:
> Hi,
>
> Thank you all.
> I need to merge lines that are in certain distances. Lines represent the
> roads. The result looks like some dashed lines. if they are not merged.
>
> Previously I tried geos lib's linemerger function. The result was not
> satisfactory.
>
> I looked at boost's append. It is for appending point to a line.
>
> What am I looking for appending a line to another line if it is in certain
> distance ( may be a threshold value).
>
> I am going to look at bg::distance().
>
> Do you have any other recommendations ?
>
> regards
>
>
>
> On Thu, Sep 19, 2019 at 7:12 PM Adam Wulkiewicz via Geometry <
> geometry_at_[hidden]> wrote:
>
>> W dniu 19.09.2019 o 15:09, Mateusz Loskot via Geometry pisze:
>> > On Thu, 19 Sep 2019 at 13:01, Ahmet Temiz via Geometry
>> > <geometry_at_[hidden]> wrote:
>> >> I want to merge some partial lines (roads) to a continuous single line
>> based on certain proximity.
>> >>
>> >> Can you guide me to use relevant function?
>> > Have you browsed through the API reference for potential candidates?
>> >
>> > For example, this one
>> >
>> https://www.boost.org/libs/geometry/doc/html/geometry/reference/algorithms/append.html
>> > and this may be helpful
>> >
>> https://github.com/boostorg/geometry/blob/develop/example/02_linestring_example.cpp
>>
>> Well, I don't know if that's what is needed here. AFAIU there is some
>> reference line (linestring or segment?) and the problem is that some
>> other lines that are closer than some distance threshold should be
>> filtered out from a set of these other lines. Is that correct? If it is
>> then you probably only need bg::distance() or bg::comparable_distance().
>> But these functions will return the minimum distance between two
>> linestrings so if you define proximity differently then you'll need
>> something else.
>>
>> So if the above does not apply please expand the explanation of the
>> problem defining what does "partial lines", "merge", "continuous single
>> line" and "proximity" mean exactly.
>>
>> Adam
>>
>> _______________________________________________
>> Geometry mailing list
>> Geometry_at_[hidden]
>> https://lists.boost.org/mailman/listinfo.cgi/geometry
>>
>
>
> --
> Ahmet Temiz
> Jeoloji Müh.
> Afet ve Acil Durum Yönetimi BaÅkanlıÄı
> Bilgi Ä°Ålem Dairesi BaÅkanlıÄı-CBS Grubu
>
>
> ________________________
>
> Ahmet Temiz
> Geological Eng.
> Information Systems - GIS Group
> Disaster and Emergency Management
> of Presidency
> _______________________________________________
> Geometry mailing list
> Geometry_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/geometry
>
Geometry list run by mateusz at loskot.net