Author Topic: Therion - create centerline svg with stations as objects?  (Read 1015 times)

Offline rhyst

  • Newbie
  • *
  • Posts: 29
  • ICCC/NPC
Therion - create centerline svg with stations as objects?
« on: February 19, 2020, 05:22:13 pm »
Hello,

Currently redrawing old surveys in Therion. The workflow is:

1) Export centerline to svg
2) Open in inkscape using therion plugins
3) Using the svg as a trace mark all the stations as station objects
4) Draw the passage around the centerline
5) Save as th2

Step 3 seems unnecessary. Is there a way to export a centerline svg where the stations are either actual objects (like the ones used by the therion inkscape plugin). It seems like all the information is there but I have no idea how to do that using therion.

The centerline export config looks like this:

source passage.th
layout test
 scale 1 500
 endlayout
export map -projection plan -o passage.svg -layout test -layout-debug station-names

Thanks for any help!

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1909
Re: Therion - create centerline svg with stations as objects?
« Reply #1 on: February 19, 2020, 07:09:28 pm »
it depends how "quick and dirty" you want it.

The other week I quickly sketched around the nettle pot passages so I could export to kml and overlay on google maps(/earth). I expect this may be one of your intended outcomes.

My example from District 9, Marniosa in spain is a survey which was made using trad techniques and the centreline printed from survex and drawn "out in the field (rather than uk)" before the bar. Therion would have coped with the original sketches and warped the image to fit the survey points. but it's far easier to redraw using the survex as a skeleton.

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1909
Re: Therion - create centerline svg with stations as objects?
« Reply #2 on: February 19, 2020, 07:16:31 pm »
If you are doing part old surveys, then it's important to use the Scalebar, the red arrow in the nettle pot example (copyright admission it's from Caves of the Peak district).

in this case I had to use trig to work out the "real scale points", I guessed nettle sits on a NW-SE heading and then had to amend the scalebar points, as therion needs to know where the ends of the scalebar are in relation to W-E.

in this case it's -35.35, 35.35||||| 35.35, -35.35
or 50sin(45)

Offline Steve Clark

  • Newbie
  • *
  • Posts: 20
Re: Therion - create centerline svg with stations as objects?
« Reply #3 on: February 19, 2020, 08:37:13 pm »
I'm possibly misunderstanding.

Do you have the original centreline survey data ?

What format do you have the old survey drawing in? (something drawn by hand & scanned or a vector/coreldraw/CAD type format?)

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1909
Re: Therion - create centerline svg with stations as objects?
« Reply #4 on: February 19, 2020, 08:39:39 pm »
Probably important to also note that I've skipped the SVG step and just gone straight for JPG as a background image, as in the Nettlepot example, see the background images tab.

The use of the red scalebar arrow is not necessary in the district9 example, as there is a full centreline driving the image and giving it orientation and scale. however in the Nettlepot example it is necessary, as it only has one point defined (the entrance) and the rest of the survey just swings about this one point (hence the old rule that all scraps must have at least one point).

There is a third method of driving survey data in therion (there's probably more). but that is to use an existing survex (.3d) model. This is not a viable option if you want to switch between using the .3d data for some subsurveys and a full centreline in others to overlay the image on Googlemaps, as .3d files come with their own coordinate system.

For this reason in the Marniosa project I've been working on I've got two .th files pulling it together.
 see Marniosamaster.th and compare it to marniosaGPS.th
with specific reference to the centreline
Quote
centreline
cs  UTM30N
station 1.0@Silvestre.SilvestreMaster "Silvestre" entrance
fix 1.0@Silvestre.SilvestreMaster 0360751 4789715 1130
equate 1944@Electronica.SilvestreMaster 0@marniosa_upstream_3


source http://cave-registry.org.uk/svn/Andara/Tresviso/Marniosa/therion/


Below is an example of how I've driven a therion file set with the .3d file.


I've included the .3d file by using import MarniosaReport2019.3d -survey use

in the top left hand corner, then I've used the "aven" application to match up where I want the points, notice here I've only included the entrance. Bottom left in the grey bar it says -name Marniosa.entrance_pda.1


this is inputted in topright box "points" under the options header -name ….

this relates directly to the .3d file top left, except the name marniosareport2019 has been chopped off. remember to use the scale bar in this, as the background image will be any old orientation you've scanned it in.

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1909
Re: Therion - create centerline svg with stations as objects?
« Reply #5 on: February 19, 2020, 09:10:30 pm »
The therion wiki is a great source of knowledge, as is the therion manual, except the therion manual can get quite heavy quite fast.

https://therion.speleo.sk/wiki/doku.php


try to use some of the point (green arrow) and line (blue arrow) commands in the .th2 interface.


but make sure they are contained in between their own scrap (purple arrow), use a new scrap for changes in height and also overlaying/underlaying passage.


if you don't use a new scrap, then the software will not know where the walls of your passage are.
 like for example the earlier example of Marniosa where I droned on about using 3d files, you can see that the highlighted passage walls are one scrap (above), the greyed out passage walls are another scrap (below), the software would not know what was going on otherwise.

Offline rhyst

  • Newbie
  • *
  • Posts: 29
  • ICCC/NPC
Re: Therion - create centerline svg with stations as objects?
« Reply #6 on: February 20, 2020, 08:19:52 pm »
Thanks for the responses! I'll try and clarify what I'm trying to do.

I have a lot of survex data which has been 'converted' to therion data. A file for example might look like this:

==================atlantis.th===================
survey atlantis -title "Atlantis"

input atlantis-p.th2

map matlantis-p -projection plan
    atlantis-1p
endmap

centreline
    team "Rhys Tyers" insts
    team "Gergely Ambrus" notes
    explo-team "Rhys Tyers"
    explo-team "Gergely Ambrus"
    date 2012.7.27
    units length meters
    units compass clino degrees
    data normal from to tape compass clino ignoreall
    2   1   16.83   198   -16
    3   2   14.72   212   -17
    4   3   17.88   180   -8
    5   4   15.76   206   -16
    6   5   20.75   183   -10
    7   6   18.12   193   -7
    8   7   14.40   140   -6
    9   8   29.80   181   -5
    10   9   13.87   168   0
    11   10   8.54   132   +6
    12   11   6.58   182   -7
    13   12   11.91   207   -17
    14   13   10.96   163   +3
    15   14   7.83   111   +12
    16   15   9.07   169   +2
    17   16   11.95   177   -14
    18   17   13.18   218   -18
    19   18   26.61   195   -14
    20   19   8.79   143   +6
    21   20   11.84   090   +18
    22   21   13.81   175   -4
    23   22   9.27   160   -3
    24   23   25.04   179   -8
    25   24   14.27   183   -14
    26   25   10.31   173   -24
    27   26   20.24   165   +7
    28   27   7.32   156   -2
    29   28   5.34   128   +4
    30   29   4.12   152   +12
    31   30   4.38   121   +22
    32   31   2.48   058   +10
endcentreline
endsurvey

# Converted From SVX
#;####Atlantis####:
#; ###Continuation of Lost Miles###
#*date 2012.7.27 ; Expedition Sledi Vetra
#
#;Tape: Rhys Tyers
#;Book + Instruments: Gergely Ambrus
#
#;Data entered by Gergely / Rhys on 2012.7.29
#
#*begin atlantis
#*data normal from to tape compass clino ignoreall
#;data normal bcra grade 5
#;from   to      tape    comp    clino; L R U D
#;Data on 3 pages
#;Page 1/3
#2   1   16.83   198   -16
#3   2   14.72   212   -17
#4   3   17.88   180   -8
#5   4   15.76   206   -16
#6   5   20.75   183   -10
#7   6   18.12   193   -7
#8   7   14.40   140   -6
#9   8   29.80   181   -5
#10   9   13.87   168   0
#11   10   8.54   132   +6
#12   11   6.58   182   -7
#13   12   11.91   207   -17
#
#;Page 2/3
#14   13   10.96   163   +3
#15   14   7.83   111   +12
#16   15   9.07   169   +2
#17   16   11.95   177   -14
#18   17   13.18   218   -18
#19   18   26.61   195   -14
#20   19   8.79   143   +6
#21   20   11.84   090   +18
#22   21   13.81   175   -4
#23   22   9.27   160   -3
#24   23   25.04   179   -8
#25   24   14.27   183   -14
#;Page 3/3
#26   25   10.31   173   -24
#27   26   20.24   165   +7
#28   27   7.32   156   -2
#29   28   5.34   128   +4
#30   29   4.12   152   +12
#31   30   4.38   121   +22
#32   31   2.48   058   +10
#
#;NOTES
#;Flip of page 1
#;Sta 1 is PSS
#
#;Flip of page 2
#;Station 21 is PSS
#
#;Flip of page 3
#;Sta 32 is Sta 1 in East Link/Lost Miles
#;Station 22 is Minestrone 2 Station 1
#
#;LRUD Data as below - introduce a new *data line if there's breaks in the survey
#;*data passage station left right up down ignoreall
#
#*end atlantis
#
#*equate atlantis.22 minestrone2.1
#*equate atlantis.32 eastlinks.1
#
==================atlantis.th===================

You can see the original data from the SVX as a comment.

I also have for reference old drawn surveys which were drawn in Inkscape around an exported centerline from Survex. I have the original files for these. I am now trying to redraw these in Therion.

The workflow I have been shown is:

- Use Therion to export an SVG image of the centerline (from atlantis.th)
- Create a blank map file (atlantis-p.th2)
- Open this blank map file in Inkscape using the Inkscape Therion Plugin.
- Import the image of the centerline into the map
- Individually mark stations in the scrap layer by pasting a station object over the stations in the imported SVG image.
- Once stations are marked, draw the passage
- Save etc.

It seems like it should be possible to take the centerline data (from atlantis.th) and export the stations directly into Therion map/scrap to start drawing around without needing this intermediate step of the centerline background image.

Offline Steve Clark

  • Newbie
  • *
  • Posts: 20
Re: Therion - create centerline svg with stations as objects?
« Reply #7 on: February 21, 2020, 06:00:28 pm »
What about :

Export an Xvi of the centreline.
Import this into therion map editor
Create a scrap with the correct projection
Select point type station
Click on each station point in the xvi and the editor will create a station
(Double check the station names)
Save the .th2 file

Offline Steve Clark

  • Newbie
  • *
  • Posts: 20
Re: Therion - create centerline svg with stations as objects?
« Reply #8 on: February 21, 2020, 06:09:50 pm »
To export the xvi, create a compile file with the following in it :

source passage.th
select matlantis-p@atlantis
export map -projection plan -output example.xvi

(This is our standard workflow for drawing up diving surveys. It works much better if you have the LRUD data. The xvi has much more detail as a skeleton.)


Offline alastairgott

  • forum hero
  • *****
  • Posts: 1909
Re: Therion - create centerline svg with stations as objects?
« Reply #9 on: February 21, 2020, 08:37:30 pm »
Hi Rhys, yes, out on the beers with work at the mo, but probably best to look at https://therion.speleo.sk/wiki/_media/conversion_of_svg_file_to_therion_format.pdf

I’m afraid it is arse over tit in my opinion, as doesn’t take into account overlying/underlying passages, but serves the purpose for basic translation of large single plane caves.

Larger caves will require more thrashing into shape.

Or you use background image and place your survey markers within the background image of the passage walls.

If you’ve got a small version use my username and add [at] hotmail.com

I’ll take a look if you want.

Offline rhyst

  • Newbie
  • *
  • Posts: 29
  • ICCC/NPC
Re: Therion - create centerline svg with stations as objects?
« Reply #10 on: February 21, 2020, 09:30:00 pm »
Solved! By using the XVI files. As they actually export the 2d position associated with the station you can pull it out using a script and dump them into a th2 file. Thanks for all the suggestions and links. This is the script I ended up with.

##### initiliase_map.py #####
import os
from os.path import isfile, join
import sys
import re

# Create scrap template (th2) with survey points and center line, and insert map definition into
# th file, ready to start drawing.
#
# Usage:
#
# python initiliase_map.py


# Templates

xvi_file = '''source {th_file}
layout test
  scale 1 500
  endlayout
export map -projection plan -o xvi.xvi -layout test -layout-debug station-names'''

scrap_file = '''encoding  utf-8
##XTHERION## xth_me_area_adjust 0 0 1004.000000 1282.000000
##XTHERION## xth_me_area_zoom_to 100

scrap DELETE-ME-survey-legs -projection plan -scale [0.0 0.0 500 1000.0 0.0 0.0 150 300]
{lines}
endscrap

scrap {name}-1p -projection plan -scale [0.0 0.0 500 1000.0 0.0 0.0 150 300]
{points}
endscrap
'''

map_fragment = '''
input {name}-p.th2

map m{name}-p -projection plan
    {name}-1p
endmap

'''

point = """point {x} {y} station -name {station}"""

line_t = """line wall
  {x1} {y1}
  {x2} {y2}
endline"""

# Find .th file
th_files = [f for f in os.listdir(os.getcwd()) if isfile(
    join(os.getcwd(), f)) and f.endswith('.th')]
if (len(th_files) > 1):
    print('Error: More than one th file.')
    sys.exit(1)
th_file = th_files[0]

name = th_file.replace('.th', '')

# Create the XVI config
with open('xvi.thconfig', 'w+') as f:
    f.write(xvi_file.format(th_file=th_file))
os.system('therion xvi.thconfig')
os.remove('xvi.thconfig')

# Extract the stations from the XVI
points = []
lines = []
with open('xvi.xvi', 'r') as f:
    xvi_lines = f.readlines()
    xvi_lines.reverse()
    for line in xvi_lines:
        match = re.search("{\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)\s*(\d+)\s*}", line)
        if match:
            x = match.groups()[0]
            y = match.groups()[1]
            station = match.groups()[2]
            points.append(point.format(x=x, y=y, station=station))
        match = re.search(
            "{\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)\s*}", line)
        if match:
            x1 = match.groups()[0]
            y1 = match.groups()[1]
            x2 = match.groups()[2]
            y2 = match.groups()[3]
            lines.append(line_t.format(x1=x1, y1=y1, x2=x2, y2=y2))
os.remove('xvi.xvi')

# Write the scrap file
with open('{name}-p.th2'.format(name=name), 'w+') as f:
    f.write(scrap_file.format(name=name, points='\n'.join(
        points), lines='\n'.join(lines)))

# Insert the map definition into the th file
th_contents = []
with open(th_file, 'r') as f:
    th_contents = f.readlines()
os.remove(th_file)

with open(th_file, 'w+') as f:
    for line in th_contents:
        if line.startswith('centreline'):
            f.write(map_fragment.format(name=name))
        f.write(line)

Offline alastairgott

  • forum hero
  • *****
  • Posts: 1909
Re: Therion - create centerline svg with stations as objects?
« Reply #11 on: February 21, 2020, 09:50:39 pm »
Is this a script you found online, or do you think it will help others with their projects.

If you think it will help others then please ensure you Sign up to the therion mailing list and send it there https://therion.speleo.sk/contact.php

This is not just a UK mailing list, all users around the world use it so typically an answer might take a couple of hours rather than days (and will typically be better than mine, unless I reply ;) )

But if you tell them what your script does then I'm sure they will go wild for it :)

Offline Steve Clark

  • Newbie
  • *
  • Posts: 20
Re: Therion - create centerline svg with stations as objects?
« Reply #12 on: February 21, 2020, 09:55:48 pm »
Great :)

You can also use xvi to export section/elevation data on any vertical plane you like, eg. if you are trying to replicate an old section on a particular bearing. Use :

export map -projection [elevation 45 deg] -output example.xvi

 

Main Menu

Forum Home Help Search