I have spent a couple of days looking over a few options with getting a grid onto the survey I sent around last week. below are the things I have tried.
I did this as this had been suggested to me and was a good solution, but at the 40-50m spacing required to get the grid to show in full this left the top right and bottom right corners with duplicate coordinates written over each other. for a finished survey, this would not be an optimal solution to the problem.
I'm not a coder but I tried to look at the C++/Cxx code for therion to try and make some amendments, but didn't realise when I tried to use it in the thconfig file, that it doesn't work the same as "code metapost". but when taking a look at it I found chunks of the code which I thought were relevant, and include these below my signature.
As the Manipulation of the frequency of the Grid spacing went ok, I decided I could potentially use this to create a background for the survey but including it in the files, I didn't make a plan (and wouldn't repeat) but this went along the lines of:
I think I could have skipped some of the above steps and used John Stevens example of drawing gridlines on a .th2 file earlier, advantages - get gridlines where you want, disadvantages - time consuming and potential for gridlines which don't look as polished as if a piece of software were doing it for you.
...etc...
If anyone has any experience of it could they make a small script (like topparser is) that can make a .th file such as the above. My thoughts are that with a few small options this could be a quick win for a few people who are manually making their own grids.
Therion already has an option to output coordinates for the bbox, these could be inputted into the script and then an option selected for the coordinate system, grid spacing, labeling frequency and placement
Regards,
Alastair Gott.
-------------------
Therion source code I thought was most closely aligned to the above problem.
CXX to control grid formation and pattern
from line 775 on therion/thpdf.cxx
GRIDLIST.clear();
if (LAYOUT.grid > 0) {
converted_data scr;
double a,b,c,d;
parse_eps(LAYOUT.gridAA, "",0,0,a,b,c,d,scr,101); GRIDLIST.push_back(scr);scr.clear();
LAYOUT.gridcell[0].x = a;
LAYOUT.gridcell[0].y = b;
parse_eps(LAYOUT.gridAB, "",0,0,a,b,c,d,scr,102); GRIDLIST.push_back(scr);scr.clear();
LAYOUT.gridcell[1].x = a;
LAYOUT.gridcell[1].y = b;
parse_eps(LAYOUT.gridAC, "",0,0,a,b,c,d,scr,103); GRIDLIST.push_back(scr);scr.clear();
LAYOUT.gridcell[2].x = a;
LAYOUT.gridcell[2].y = b;
parse_eps(LAYOUT.gridBA, "",0,0,a,b,c,d,scr,104); GRIDLIST.push_back(scr);scr.clear();
LAYOUT.gridcell[3].x = a;
LAYOUT.gridcell[3].y = b;
parse_eps(LAYOUT.gridBB, "",0,0,a,b,c,d,scr,105); GRIDLIST.push_back(scr);scr.clear();
LAYOUT.gridcell[4].x = a;
LAYOUT.gridcell[4].y = b;
parse_eps(LAYOUT.gridBC, "",0,0,a,b,c,d,scr,106); GRIDLIST.push_back(scr);scr.clear();
LAYOUT.gridcell[5].x = a;
LAYOUT.gridcell[5].y = b;
parse_eps(LAYOUT.gridCA, "",0,0,a,b,c,d,scr,107); GRIDLIST.push_back(scr);scr.clear();
LAYOUT.gridcell[6].x = a;
LAYOUT.gridcell[6].y = b;
parse_eps(LAYOUT.gridCB, "",0,0,a,b,c,d,scr,108); GRIDLIST.push_back(scr);scr.clear();
LAYOUT.gridcell[7].x = a;
LAYOUT.gridcell[7].y = b;
parse_eps(LAYOUT.gridCC, "",0,0,a,b,c,d,scr,109); GRIDLIST.push_back(scr);scr.clear();
LAYOUT.gridcell[8].x = a;
LAYOUT.gridcell[8].y = b;
}
PATTERNLIST.clear();
std::ifstream P("patterns.dat");
if(!P) therror(("Can't open patterns definition file!"));
char buf[5000];
char delim[] = ":";
std::string line,num,pfile,bbox,xstep,ystep,matr;
while(P.getline(buf,5000,'\n')) {
num = strtok(buf,delim);
pfile = strtok(NULL,delim);
bbox = strtok(NULL,delim);
xstep = strtok(NULL,delim);
ystep = strtok(NULL,delim);
matr = strtok(NULL,delim);
// if (ALL_PATTERNS.count(num) > 0) { // changed to patt.used flag
// because thsymbolset.cxx
// calls eps_parse after
// this function is called
// and patterns referenced
// there would be missing in this list
pattern patt;
patt.used = (ALL_PATTERNS.count(num) > 0);
matr.replace(matr.find("["),1,"");
matr.replace(matr.find("]"),1,"");
std::istringstream s1(matr);
s1 >> patt.xx >> patt.xy >> patt.yx >> patt.yy >> patt.x >> patt.y;
bbox.replace(bbox.find("["),1,"");
bbox.replace(bbox.find("]"),1,"");
std::istringstream s2(bbox);
s2 >> patt.llx >> patt.lly >> patt.urx >> patt.ury;
// F << "/Matrix " << matr << endl;
// F << "/BBox " << bbox << endl;
patt.xstep = atof(xstep.c_str());
patt.ystep = atof(ystep.c_str());
parse_eps(pfile , "", 0,0, patt.llx1,patt.lly1,patt.urx1,patt.ury1,patt.data,0);
PATTERNLIST.push_back(patt);
// } // patt.used
}
P.close();
}
Cxx for Bounding control
This was the first bit of code I noted down, before I kept proper refs of them, think it was Located in xtherion/thepsparse.cxx/from line 1336
if (J->second.minx > Llx) J->second.minx = Llx;
if (J->second.miny > Lly) J->second.miny = Lly;
if (J->second.maxx < Urx) J->second.maxx = Urx;
if (J->second.maxy < Ury) J->second.maxy = Ury;
Cxx for Layout Calibration
two bits of code seem to be working together with the use of LAYOUT.calibration_hdist
code from Therion/thpdf.cxx/1620-1621
PAGEDEF << "\\pdfcatalog { /thCalibrate (HS=\\the\\adjustedHS, VS=\\the\\adjustedVS, HD=" <<
fmt::format("{}",thdouble(LAYOUT.calibration_hdist,10)) << ")}";
2) code from therion/thexpmap.cxx/line 1862-1871
calpoint(0, lim.min.x, lim.min.y);
calpoint(1, (lim.min.x + lim.max.x) / 2.0,lim.min.y);
calpoint(2, lim.max.x, lim.min.y);
calpoint(3, lim.min.x, (lim.min.y + lim.max.y) / 2.0);
calpoint(4, lim.max.x, (lim.min.y + lim.max.y) / 2.0);
calpoint(5, lim.min.x, lim.max.y);
calpoint(6, (lim.min.x + lim.max.x) / 2.0,lim.max.y);
calpoint(7, lim.max.x, lim.max.y);
calpoint(8, (lim.min.x + lim.max.x) / 2.0, (lim.min.y + lim.max.y) / 2.0);
LAYOUT.calibration_hdist = lim.max.x - lim.min.x;
Cxx for Adjustments
code from Therion/thpdf.cxx/1598-1608
PAGEDEF << "\\adjustedHS=" << fmt::format("{}",thdouble(HS,prec_xy)) << "bp" <<
"\\advance\\adjustedHS by \\extraE" <<
"\\advance\\adjustedHS by \\extraW" <<
"\\advance\\adjustedHS by \\overlap" <<
"\\advance\\adjustedHS by \\overlap" << std::endl;
PAGEDEF << "\\adjustedVS=" << fmt::format("{}",thdouble(VS,prec_xy)) << "bp" <<
"\\advance\\adjustedVS by \\extraN" <<
"\\advance\\adjustedVS by \\extraS" <<
"\\advance\\adjustedVS by \\overlap" <<
"\\advance\\adjustedVS by \\overlap" << std::endl;