Skip to content

Commit

Permalink
generate cross points for new pages
Browse files Browse the repository at this point in the history
  • Loading branch information
kiang committed Apr 6, 2014
1 parent 77222ba commit db6ba35
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion scripts/kiang/9_cell_debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,17 @@
foreach ($matches AS $xMod => $xStack) {
foreach ($xStack AS $yMod => $yStack) {
foreach ($yStack AS $imageId => $cellReference) {
$oFile = $oFileStack[$imageId];
$lines = array(
'width' => $oFile[4],
'height' => $oFile[5],
'horizons' => array(),
'verticles' => array(),
'cross_points' => array(),
);

$oJson = json_decode(file_get_contents($path . '/pdf/cells/' . $cellReference . '.json'));
$oLines = json_decode(file_get_contents($path . '/pdf/lines/' . $cellReference . '.json'));
$cellCount = 0;
foreach ($oJson->cells AS $line) {
foreach ($line AS $cell) {
Expand All @@ -195,9 +205,19 @@
++$cellCount;
}
}

foreach($oLines->cross_points AS $lineKey => $line) {
$lines['cross_points'][$lineKey] = array();
foreach ($line AS $pointKey => $point) {
$lines['cross_points'][$lineKey][$pointKey] = array(
0 => $point[0] + $xMod,
1 => $point[1] + $yMod,
);
}
}

$imageObj = new stdClass();
$oFile = $oFileStack[$imageId];

$imageObj->image_id = $imageId;
$imageObj->document = $oFile[1];
$imageObj->page_no = $oFile[2];
Expand All @@ -207,6 +227,7 @@
$imageObj->cells = $oJson->cells;
$imageObj->cellCount = $cellCount;
file_put_contents($path . '/pdf/cells/' . $imageId . '.json', json_encode($imageObj));
file_put_contents($path . '/pdf/lines/' . $imageId . '.json', json_encode($lines));
}
}
}
Expand Down

0 comments on commit db6ba35

Please sign in to comment.