We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

Find coordinates of path points [closed]

asked 2017-03-15 21:30:08 +0200

PerceptualRobots gravatar image

I have a "path" object defined by this, as shown with the image,

<draw:path draw:style-name="gr19" draw:text-style-name="P11" draw:layer="layout" svg:width="1.806cm" svg:height="5.999cm" svg:x="71.193cm" svg:y="21cm" svg:viewbox="0 0 1807 6000" svg:d="M1800 6000c-100-1600-1800-800-1800-2400 0-1100 1707-500 1807-1600-100-1100-1107-500-1007-2000"> <text:p text:style-name="P9"><text:span text:style-name="T4">Path</text:span></text:p> </draw:path>

image description

How can I work out what the coordinates of the endpoints of the line are?

I am using the drawing as a control system configuration and want to know which objects are linked by path connectors.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-09-27 20:35:48.367233

1 Answer

Sort by » oldest newest most voted

answered 2017-03-17 00:40:54 +0200

Regina gravatar image

In case you need the coordinates in the internal coordinate system, you have to calculate it yourself (see below) or write a macro to do it for you. In case you need the coordinates in the page coordinate system, you can look at the status bar or the position dialog or you put a snap point at the same position and read its coordinates.

The path is defined as svg:d which means, it is the definition as can be read in http://www.w3.org/TR/SVG/expanded-toc....

M1800 6000 is an absolute move to (1800|6000) and the start anchor point of the following Bézier segment.

A c means a Bézier curve. Such has for each segment two control points and the end anchor point, which is the start point of the next segment. The c is not repeated for the next segment. As the c is lower case, the coordinates are relative to the start anchor point.

c-100-1600-1800-800-1800-2400 means: control points (1700|4400) (0|5200) next anchor point (0|3600)

0-1100 1707-500 1807-1600 means: control points (0|2500) (1707|3100) next anchor point (1807|2000)

-100-1100-1107-500-1007-2000 means: control points (1707|900) (900|1500) last anchor point (800|0).

For to know the connected objects do not use the path. A connector has the attributes draw:start-shape and draw:start-glue-point and draw:end-shape and draw:end-glue-point. These gives you the information directly. If you save the document in flat ODF (= file name extension fodt) and open it in an editor, then you will find these attributes easily. You can get these information using a macro.

edit flag offensive delete link more


Thanks. I am reading the XML from Java. Did you mean a glue point? I tried to add one to the line but it doesn't move with the line.

"c-100-1600-1800-800-1800-2400 means: control points" I'm not quite with you. Are these numbers x and y distances from the bottom left corner?

PerceptualRobots gravatar imagePerceptualRobots ( 2017-03-17 18:15:28 +0200 )edit

The coordinates inside the shape are based on svg:viewbox="0 0 1807 6000", which is left,top,width,height. That rectangle is mapped to svg:width="1.806cm" svg:height="5.999cm" svg:x="71.193cm" svg:y="21cm", which is relative to the page coordinate system.

Regina gravatar imageRegina ( 2017-03-17 18:59:32 +0200 )edit

The shape has an xml:id and this number is in draw:start-shape if the connector is docked to that shape. To which glue-point of that shape the connector is docked is in draw:start-glue-point. Each shape has four default glue points with the numbers 0, 1, 2, 3. The other glue points are defined inside the shape. They can be an attribute draw:glue-points of the element <draw:enhanced-geometry> or they can be user defined in an <draw:glue-point> element as child of element <draw:custom-shape>.

Regina gravatar imageRegina ( 2017-03-17 19:16:27 +0200 )edit

Do you work on the file source or do you have a running LibreOffice so that you can get current information via API?

Regina gravatar imageRegina ( 2017-03-17 19:22:35 +0200 )edit

I am using the Java odg toolkit API to read in an ODG document, from which I get the XML code for an object. And I want to determine the coordinates of the line end points within the page coordinate system. So if "c-100-1600-1800-800-1800-2400" are relative to the top left corner how do I know if these values are in the x or y directions?

PerceptualRobots gravatar imagePerceptualRobots ( 2017-03-18 11:21:27 +0200 )edit

You need to read the SVG specification, its link I have given in my answer. In case of the c command, it is first number x, second number y (=>first control point), third number x, forth number y (=>second control point), fifth number x, sixth number y (=> anchor point) and so on. From the information svg:width, svg;height, svg:x, svg:y, svg:viewbox you generate a transformation matrix. Apply this matrix to the internal path coordinates to get the position on the page.

Regina gravatar imageRegina ( 2017-03-18 12:23:06 +0200 )edit

Because you only need the last point, you can skip the control points.

Regina gravatar imageRegina ( 2017-03-18 13:28:39 +0200 )edit

Question Tools

1 follower


Asked: 2017-03-15 21:30:08 +0200

Seen: 1,020 times

Last updated: Mar 17 '17