numshapes; $i++) { $shape = $shapefile->getShape($i); if($selectionShape->numlines <= 0) { for($l = 0; $l < $shape->numlines; $l++) { $selectionShape->add($shape->line($l)); } } else { $selectionShape = $selectionShape->union_geos($shape); } } $shapefile->free(); $parcelsMap = ms_newMapObj($PARCELS_MAP); $shapes = getShapesFromLayer($parcelsMap, $PARCELS_LAYER, $selectionShape); $parcels = $parcelsMap->getLayerByName($PARCELS_LAYER); $parcels->open(); $columns = getLayerColumnHash($parcels); $numShapes = count($shapes); $numLines = count($LABEL_LINES); $addressLabels = array(); $currentLabel = 0; for($i = 0; $i < $numShapes; $i++) { $addressLines = array(); $currentLine = 0; for($l = 0; $l < $numLines; $l++) { $line = $LABEL_LINES[$l]; foreach($columns as $key => $value) { $line = preg_replace('/\['.$key.'\]/', $shapes[$i]->getvalue($parcels,$key), $line); $line = preg_replace('/ +/',' ',$line); $line = preg_replace('/^ */','',$line); } if(($COLLAPSE_LINES == 1 and $line != ' ' and $line != '') or $COLLAPSE_LINES != 1) { $addressLines[$currentLine] = $line; $currentLine++; } } $addressLabels[$currentLabel] = $addressLines; $currentLabel++; } $parcels->close(); if($outputFormat == 'html') { print "\n"; print "GeoMOOSE Address Labels Output\n"; print "\n"; foreach($addressLabels as $label) { foreach($label as $line) { print $line."
\n"; } print "
\n"; } print ""; print ""; } elseif($outputFormat == 'csv') { header('Content-type: text/csv'); $columnTitles = array(); for($i = 0; $i < $numLines; $i++) { $columnTitles[$i] = "LINE".($i+1); } $str = '"'.implode('","',$columnTitles)."\"\n"; print $str; foreach($addressLabels as $label) { $str = '"'.implode('","',$label)."\"\n"; print $str; } } elseif($outputFormat == 'pdf') { header('Content-type: application/pdf'); # This prevents fpdf from being loaded if it's not needed. require($FPDF_LOCATION.'fpdf.php'); # New PDF Object $PageSize = array(11,8.5); $pdf = new FPDF('L','in', $PageSize); $pdf->SetAutoPageBreak(false); $pdf->AddPage(); $pdf->SetMargins(.5,.5,.5); $pdf->SetFont($LABEL_FONT,'',$LABEL_FONT_SIZE); $pdf->SetTextColor(0,0,0); $CurrentX = $LABEL_ORIGIN_X; $CurrentY = $LABEL_ORIGIN_Y; $CurrentRow = 0; $CurrentColumn = 0; foreach($addressLabels as $label) { $lineY = $CurrentY; foreach($label as $line) { $lineFontSize = $LABEL_FONT_SIZE; $pdf->SetXY($CurrentX,$lineY); if($LABELS_AUTOFIT_WIDTH) { while($pdf->GetStringWidth($line) > $LABEL_WIDTH) { $lineFontSize--; $pdf->SetFontSize($lineFontSize); } } $pdf->Cell(0,.25,$line,0,0,'L'); # Make the lines even despite variable sizes $lineY = $lineY + $LABEL_FONT_SIZE/72; } $CurrentY += $LABEL_HEIGHT; $CurrentRow++; if($CurrentRow >= $LABEL_ROWS) { $CurrentRow = 0; $CurrentColumn ++; $CurrentX+=$LABEL_WIDTH; $CurrentY = $LABEL_ORIGIN_Y; if($CurrentColumn >= $LABEL_COLUMNS) { $CurrentColumn = 0; $CurrentRow = 0; $CurrentY = $LABEL_ORIGIN_Y; $CurrentX = $LABEL_ORIGIN_X; $pdf->AddPage(); $pdf->SetMargins(.5,.5,.5); } } } #$pdf->Output('out.pdf'); $pdf->Output(); } ?>