OpenCPN / OpenCPN

A concise ChartPlotter/Navigator. A cross-platform ship-borne GUI application supporting * GPS/GPDS Postition Input * BSB Raster Chart Display * S57 Vector ENChart Display * AIS Input Decoding * Waypoint Autopilot Navigation
https://opencpn.org/
GNU General Public License v2.0
1.06k stars 504 forks source link

Question: How to convert hpgl vector data into svg? #3462

Closed oliveever closed 1 year ago

oliveever commented 1 year ago

The XML file contains symbol related descriptions. I copied the HPGL label content separately to create the file, but it failed to open using by HPGL Viewer and inkscape. Why can OpenCPN read and render it as an symbol🤔

<symbol RCID="1344">
    <name>GATCON03</name>
    <description>navigable lock gate</description>
    <bitmap width="21" height="21">
        <distance min="0" max="0" />
        <pivot x="10" y="10" />
        <origin x="0" y="0" />
        <graphics-location x="1318" y="121" />
    </bitmap>
    <color-ref>JTRFCD</color-ref>
    <vector width="700" height="700">
        <distance min="0" max="0" />
        <pivot x="1500" y="1500" />
        <origin x="1150" y="1150" />
        <HPGL>SPJ;PU1500,1500;SW1;CI350;PU1181,1350;PD1812,1350;PU1181,1650;PD1818,1650;PU1250,1500;PD1500,1250;PU1250,1500;PD1500,1750;PU1650,1250;PD1400,1500;PD1650,1750;</HPGL>
    </vector>
    <definition>V</definition>
</symbol>
leamas commented 1 year ago

hm... Unless I miss somethin that link https://github.com/OpenCPN/OpenCPN/blob/master/data/s57data/chartsymbols.xml actually contains json, not the expected xml.

leamas commented 1 year ago

Given that this file isn't any xml file it's not strange that it cannot be opened by various tools expecting XML input.

So, what is this issue really about?

nohal commented 1 year ago

It is pretty simple, OpenCPN understands the somewhat non-standard HP-GL dialect used by IHO in the S52 presentation library.

To make a vector symbol HP-GL definition extracted from chartsymbols.xml loadable in Inkscape (still with warnings about unknown commands and with usually wrong color due to the pen number to color translation Inkscape does in a way incompatible with IHO's mind), you need to make the SP commands standard compliant = have a number at the third position, using for example sed -i -e 's/SP./SP1/g' test1.hpgl, The number is the "pen" ID, in case of Inkscape 0->White, 1->Black etc.

Anyway, I will convert this to a discussion as it is in no way an issue in OpenCPN