• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Discover Polyline Helper Functions in TMS FNC Maps

Sascha Оффлайн

Sascha

Заместитель Администратора
Команда форума
Администратор
Регистрация
9 Май 2015
Сообщения
1,486
Баллы
155
When working with polylines in your mapping applications, having a set of helper functions can significantly enhance your productivity. In this article, we’ll explore a collection of useful calls that provide extra functionality for working with polylines using the TTMSFNCMaps component.

Splitting Polylines


Split(ACoordinate: TTMSFNCMapsCoordinateRec): TTMSFNCMapsPolyline
Split(AIndex: Integer): TTMSFNCMapsPolyline

The Split function allows you to divide a polyline at a specified coordinate or index. When you call Split(ACoordinate), it splits the polyline at the provided coordinate and returns a new polyline containing the segment after the split. Similarly, Split(AIndex) splits the polyline at the specified index and returns the resulting segment as a new polyline.

TMS Software Delphi  Components

The black polyline displays a route from Chicago to Toronto passing through Detroit. A point near Detroit is selected on the polyline by a marker.​

TMS Software Delphi  Components

After splitting the polyline, the black polyline only goes up to the selected point. A new blue polyline is added which starts at the selected point.​
Merging Polylines


Merge(APolyline: TTMSFNCMapsPolyline)
Merge(ACoordinates: TTMSFNCMapsCoordinateRecArray)



Merging polylines is essential when you need to combine multiple segments into a single polyline. The Merge function allows you to merge the original polyline with another polyline or an array of coordinates. When you call Merge(APolyline), the provided polyline is added after the last coordinate of the original polyline. Alternatively, Merge(ACoordinates) merges the polyline with the specified coordinate array.

TMS Software Delphi  Components

A black polyline displays the route between Chicago and Detroit. A green polyline displays the route between Detroit and Toronto.​

TMS Software Delphi  Components

After merging both polylines, the blue polyline displays the route from Chicago to Toronto passing through Detroit.​

Extracting Segments


Segment(AStartCoordinate, AEndCoordinate: TTMSFNCMapsCoordinateRec): TTMSFNCMapsPolyline
Segment(AStartIndex, AEndIndex: Integer): TTMSFNCMapsPolyline

The Segment function extracts a segment from the original polyline. You can specify the start and end coordinates or indices to define the segment you want. The resulting segment is returned as a new polyline.

TMS Software Delphi  Components

The black polyline displays a route from Chicago to Detroit with two points selected by a marker.​

TMS Software Delphi  Components

After extracting a segment, a new blue polyline is added that displays a route between the two previously selected points.​

Finding the Nearest Coordinate


FindNearestPolylineCoordinate(ACoordinate: TTMSFNCMapsCoordinateRec; AMaxDistance: Double; var APolylineIndex: Integer; var ACoordinateIndex: Integer; var ACoordinateRec: TTMSFNCMapsCoordinateRec): Boolean

Sometimes, you need to find the nearest coordinate within a collection of polylines. The FindNearestPolylineCoordinate function does precisely that. You provide a coordinate, and the function searches for the nearest coordinate in the polylines collection. If a coordinate is found within the specified maximum distance (in meters), the function returns True. Additionally, it provides information about the polyline index, coordinate index, and the actual coordinate itself.

In the examples above this method was used to select the desired locations on the polyline. When a click occurs on the polyline, the OnPolyElementClick is triggered. The exact coordinate clicked is retrieved from the AEventData.Coordinate parameter. However, you want to know which coordinate in the polyline's coordinate array corresponds to the clicked point. This is where the FindNearestPolylineCoordinate call comes in. By using this function you can precisely determine the relevant coordinate within the polyline.


procedure TForm1.TMSFNCGoogleMaps1PolyElementClick(Sender: TObject;
AEventData: TTMSFNCMapsEventData);
var
c: TTMSFNCMapsCoordinateRec;
m: TTMSFNCMapsMarker;
PolylineIndex, CoordinateIndex: Integer;
begin
TMSFNCMaps1.FindNearestPolylineCoordinate(AEventData.Coordinate.ToRec, -1, PolylineIndex, CoordinateIndex, c);
m := TMSFNCGoogleMaps1.AddMarker(c);
m.DefaultIcon.Enabled := True;
end;

Common Helper Functions

When working with TMS FNC Maps, you’ll find a wealth of common helper functions that simplify your development tasks. These functions provide essential utilities and streamline various operations.. Like MeasureDistance for example, to measure the distance between two coordinates.
Explore the

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

to unlock their full potential.

Conclusion
These polyline helper functions simplify common tasks when working with polylines, making your mapping applications more efficient and user-friendly. Incorporate them into your projects to enhance your mapping experience!

Available Now


The

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

for Delphi update is available now. You can

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

the latest version and start using the new features right away!




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу