Links

Content Skeleton

This Page

Previous topic

svg

Next topic

scrape

SVG PLOT CHECKING/DEVELOPMENT

svgplot-get
pull the SVG from the webapp
svgplot-eta
demo nofont SVG for single char of form produced by dvisvgm

CONVERT PLOT SVG TO PDF

pycairo

No path support yet ..

inkscape

TRACING PLOT SOURCES

remote access to private servers

Open SSH socks proxy tunnels:

simon:~ blyth$ ssh -fND localhost:8080 K
simon:~ blyth$ ssh -fND localhost:9090 K

For details, and browser/curl config to use the proxy see env:base/ssh

cocoon sitemap

Directs a URL regexp to cocoon XML generator plot.xq

851              <map:match type="regexp" pattern="^(0)(\d)(\d)(\d)(\d)/plot/(svg|xml)$">
852                   <map:generate src="plot.xq" type="xquery" label="sauce"  >

plot.xq generator XQuery

Request parameter handling, fork on individual or combined plot, hand over to make-plot.xqm

make-plot.xqm XQuery lib

Mostly cache control, the nitty gritty handed down to rezs.xqm

rezs:qtset2svg SVG generation

rezs:qt2svglabel

Label is returned asis from /db/hfagc_system/qtag2svgs.xml

After opening the tunnel

0039 declare variable $rezs:qtag2svgs_index  as xs:string { "/db/hfagc_system/qtag2svgs.xml" } ;
....
1618 (:
1619       this is used in individual and combi plot SVGs
1620 :)
1621 declare function rezs:qt2svglabel( $qt as xs:string , $opt as xs:string ) as element() {
1622
1623     let $label := if( doc-available($rezs:qtag2svgs_index) ) then
1624                      doc($rezs:qtag2svgs_index)//qtag[@value=$qt]/svgs/label/*
1625                   else
1626                      <text x="0" y="0"> no label[{$qt}] </text>

Check the index

Use the interactive XQuery form in the context of hfagc_system collection

To grab the indexed SVG labels:

doc("qtag2svgs.xml")//qtag[@value='BR:-521:-321,221,443']
doc("qtag2svgs.xml")//qtag[@value='BR:-521:-321,221,443']/svgs/label/*[1]     (: grabs the svg:g elem :)
doc("qtag2svgs.xml")//qtag[@value='BR:-521:-321,221,443']/svgs/sabel/*[1]     (: grabs the svg:g elem :)

Observations on the SVG:

  1. absolute path data for each bezier curved glyph has x y ranges in ballpark -9 to +9, maybe ordinary character point size units
  2. crazy large +ve y (down) translation is apparent
<svg:g exist:id ="14831" exist:source ="/db/hfagc_system/qtag2svgs.xml" id ="slBR_-521_-321+221+443" transform ="translate(154.963,6734.518)" >
     <svg:defs >
         <svg:path d ="M5.7 -3.324C5.76 -3.564 5.796 -3.708 5.796 -4.032C5.796 -4.752 5.376 -5.292 4.464 -5.292C3.396 -5.292 2.832 -4.536 2.616 -4.236C2.58 ....
         ...
     </svg:defs >
     <svg:g id ="slBR_-521_-321+221+443_page1" transform ="matrix(0.996264 0 0 0.996264 0 0)" >

         <svg:use x ="56.6248" y ="66" xlink:href ="#slBR_-521_-321+221+443_g0-74" />
         <svg:use x ="63.5776" y ="66" xlink:href ="#slBR_-521_-321+221+443_g0-61" />

         <svg:use x ="69.4525" y ="66" xlink:href ="#slBR_-521_-321+221+443_g0-32" />
         <svg:use x ="77.5219" y ="66" xlink:href ="#slBR_-521_-321+221+443_g1-40" />
         <svg:use x ="82.0913" y ="66" xlink:href ="#slBR_-521_-321+221+443_g1-49" />
         <svg:use x ="87.9662" y ="66" xlink:href ="#slBR_-521_-321+221+443_g0-83" />
         <svg:use x ="95.8911" y ="66" xlink:href ="#slBR_-521_-321+221+443_g1-41" />
         <svg:use x ="100.461" y ="66" xlink:href ="#slBR_-521_-321+221+443_g0-17" />
         <svg:use x ="106.688" y ="66" xlink:href ="#slBR_-521_-321+221+443_g0-75" />
         <svg:use x ="117.547" y ="61.6453" xlink:href ="#slBR_-521_-321+221+443_g2-0" />
     </svg:g>
 </svg:g>

Check Origin SVG from dvisvgm

/Users/heprez/data/data/images/qtags/svg_nofonts/slBR_-521_-321+221+443.svg

<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- This file was generated by dvisvgm 1.3 (x86_64-apple-darwin11.4.0) -->
<!-- Mon Jun 24 12:24:51 2013 -->
<svg height='12.1425pt' version='1.1' viewBox='56.4133 56.5997 67.2806 12.1425' width='67.2806pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
<path d='M5.7 -3.324C5.76 -3.564 5.796 -3.708 5.796 ...

<path d='M5.592 -1.816C5.72 -1.816 5.896 -1.816 5.896 -2S5.72 -2.184 5.592 -2.184H1.008C0.88 -2.184 0.704 -2.184 0.704 -2S0.88 -1.816 1.008 -1.816H5.592Z' id='g2-0'/>
</defs>
<g id='page1' transform='matrix(0.996264 0 0 0.996264 0 0)'>
<use x='56.6248' xlink:href='#g0-74' y='66'/>
<use x='63.5776' xlink:href='#g0-61' y='66'/>
<use x='69.4525' xlink:href='#g0-32' y='66'/>
<use x='77.5219' xlink:href='#g1-40' y='66'/>
<use x='82.0913' xlink:href='#g1-49' y='66'/>
<use x='87.9662' xlink:href='#g0-83' y='66'/>
<use x='95.8911' xlink:href='#g1-41' y='66'/>
<use x='100.461' xlink:href='#g0-17' y='66'/>
<use x='106.688' xlink:href='#g0-75' y='66'/>
<use x='117.547' xlink:href='#g2-0' y='61.6453'/>
</g>
</svg>

Centering the label

Taking /Users/heprez/data/data/images/qtags/svg_nofonts/slBR_-511_-311+83xoBR_-521_-321+83.svg:

<svg height='18.3592pt' version='1.1' viewBox='57.6088 53.7982 44.272 18.3592' width='44.272pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<defs>
    ...
</defs>
<g id='centering' transform='translate(-57.6088,-53.7982)'>
<g id='page1' transform='matrix(0.996264 0 0 0.996264 0 0)'>
   <path id='bbox' d="M57.6088 53.7982 h 44.272 v 18.3592 h -44.272 z" fill="none" stroke="blue" />
   <use x='58.8804' xlink:href='#g0-89' y='60.69'/>
   <use x='65.6958' xlink:href='#g1-40' y='60.69'/>
   ...
</g>
</g>
</svg>

The centering group and bbox path are based on the viewBox numbers. Instead of crazy gridification, applying such transforms at svgsmry stage can avoid the kludge constant offset.

Check the summary

Use the interactive XQuery form in the context of hfagc_system collection

declare namespace svg="http://www.w3.org/2000/svg" ;
doc("svg-summary.xml")//svg:g[@id='slBR_-521_-321+221+443']

The big transforms hail from back in during summary creation (set by the gridification done in summary creation):

<svg:g exist:id ="1540" exist:source ="/db/hfagc_system/svg-summary.xml" id ="slBR_-521_-321+221+443" transform ="translate(154.963,6734.518)" >
  <svg:defs >
     <svg:path d ="M5.7 -3.324C5.76 -3.564 5....

Kludge with fixed transform modifying query

Grab the svg:g content and construct new svg:g without the transform attribute:

declare namespace svg="http://www.w3.org/2000/svg" ;

let $qt := 'BR:-521:-321,221,443'
let $g := doc("qtag2svgs.xml")//qtag[@value=$qt]/svgs/sabel/svg:g[1]
return
       <svg:g>
           {
              attribute id {$g/@id}
              ,
              $g/*
           }
       </svg:g>

Kludge fixed offset

1620 declare function rezs:qt2svglabel( $qt as xs:string , $opt as xs:string ) as element() {
1621     let $g := doc($rezs:qtag2svgs_index)//qtag[@value=$qt]/svgs/label/svg:g[1]
1622     let $transform := "translate(0,-66)"
1623     return
1624            <svg:g>
1625            {
1626               attribute id {$g/@id}
1627               ,
1628               attribute transform {$transform}
1629               ,
1630               $g/*
1631            }
1632            </svg:g>
1633 };
1634
1635 declare function rezs:qt2svgsabel( $qt as xs:string , $opt as xs:string ) as element() {
1636     let $g := doc($rezs:qtag2svgs_index)//qtag[@value=$qt]/svgs/sabel/svg:g[1]
1637     let $transform := "translate(0,-66)"
1638     return
1639            <svg:g>
1640            {
1641               attribute id {$g/@id}
1642               ,
1643               attribute transform {$transform}
1644               ,
1645               $g/*
1646            }
1647            </svg:g>
1648 };
1649

Check old function

import module namespace rezs = "http://hfag.phys.ntu.edu.tw/hfagc/rezs" at "webapp/hfagc/xquery/rezs.xqm" ;
let $qt := 'BR:-521:-321,221,443'
return
      rezs:qt2svgsabel( $qt, "" )

Add new function

  • heprez:r908

  • propagate:

    b2mc:h heprez$ exist-up webapp/hfagc trial      # observe non-propagated D0 addition as well as the modified label funcs

Testing on dynamic plot URL, shows the label positions are now in the ball park

Grab from afar:

simon:k blyth$ curl -s --socks5 localhost:9090 http://130.87.106.59:9090/hfagc/01114/plot/svg -o 01114.svg
simon:k blyth$ open 01114.svg
simon:k blyth$ curl -s --socks5 localhost:9090 http://130.87.106.59:9090/hfagc/01214/plot/svg -o 01214.svg
simon:k blyth$ xmllint --format  01214.svg

SVG PATH

M (x y)+
moveto absolute
C (x1 y1 x2 y2 x y)+
curveto absolute
S (x2 y2 x y)+
smooth curveto absolute
L (x y)+
lineto absolute
Z
closepath