Example #1
0
function makeIndex($data, $field)
{
    include 'fieldList.php';
    $index = '';
    if (in_array($field, $normalFields)) {
        $collect = collectIDs($data, $field);
    } elseif ($field == 'persName') {
        $collect = collectIDsPersons($data);
    } elseif ($field == 'placeName') {
        $collect = collectIDsPlaces($data);
    } elseif (in_array($field, $personFields)) {
        $collect = collectIDsSubObjects($data, 'persons', $field);
    } elseif (in_array($field, $placeFields)) {
        $collect = collectIDsSubObjects($data, 'places', $field);
    } elseif (in_array($field, $manifestationFields)) {
        $collect = collectIDsAssocArrayValues($data, 'manifestation', $field);
    } elseif (in_array($field, $workFields)) {
        $collect = collectIDsAssocArrayValues($data, 'work', $field);
    } elseif (in_array($field, $originalItemFields)) {
        $collect = collectIDsAssocArrayValues($data, 'originalItem', $field);
    } elseif (in_array($field, $arrayFields)) {
        $collect = collectIDsArrayValues($data, $field);
    }
    if (isset($collect)) {
        $collect = sortCollect($collect);
        $index = makeEntries($collect, $field);
    } elseif ($field == 'catSubjectFormat') {
        $collect1 = collectIDs($data, 'histSubject');
        $index1 = makeEntries($collect1);
        unset($collect1);
        $collect2 = collectIDs($data, 'format');
        $index2 = makeEntries($collect2);
        unset($collect2);
        $index = mergeIndices($index1, $index2);
    }
    foreach ($index as $entry) {
        $entry->label = postprocessFields($field, $entry->label);
    }
    return $index;
}
Example #2
0
function makeGeoDataSheet($data, $folderName, $format)
{
    $ending = strtolower($format);
    // Anlegen eines gemeinsamen Index für Orte und Jahre, so dass beide Kategorien abgerufen werden können.
    $index1 = makeIndex($data, 'placeName');
    $index2 = makeIndex($data, 'year');
    $commonIndex = mergeIndices($index1, $index2);
    $rowArray = array();
    $placeName = '';
    // Durchgehen des Index und Abspeichern von standardisierten Datensätzen der Klasse geoDataRow im Array $rowArray
    foreach ($commonIndex as $entry) {
        // Die im Index mit Level 1 auftretenden Ortseinträge dienen nur zum Speichern von Ortsname und Geodaten
        if ($entry->level == 1) {
            // Der Test dient dem Ausschließen von Einträgen ohne Ortsnamen oder Geodaten
            $test = testEntry($entry);
            $placeName = $entry->label;
            $latitude = cleanCoordinate($entry->geoData['lat']);
            $longitude = cleanCoordinate($entry->geoData['long']);
        }
        //Für jeden Indexeintrag Level 2 (Jahre) werden so viele Einträge gespeichert, wie Datensätze unter content verzeichnet sind.
        if ($entry->level == 2 and $test == 1) {
            foreach ($entry->content as $occurrence) {
                $row = new geoDataRow();
                $row->label = $placeName;
                $row->lat = cleanCoordinate($entry->geoData['lat']);
                $row->long = cleanCoordinate($entry->geoData['long']);
                $row->timeStamp = $entry->label;
                $row->lat = $latitude;
                $row->long = $longitude;
                if ($entry->authority['system'] == 'getty') {
                    $row->getty = $entry->authority['id'];
                } elseif ($entry->authority['system'] == 'geoNames') {
                    $row->geoNames = $entry->authority['id'];
                }
                $rowArray[] = $row;
            }
        }
    }
    // Jetzt werden die Objekte der Klasse geoDataRow in Einträge übersetzt, abhängig vom gewählten Format
    if ($ending == 'csv') {
        // Kopfdaten für CSV-Dateien
        $content = '"Name","Address","Description","Longitude","Latitude","TimeStamp","TimeSpan:begin","TimeSpan:end","GettyID",""
';
        foreach ($rowArray as $row) {
            $content .= makePlaceEntryCSV($row);
        }
    } elseif ($ending == 'kml') {
        // Kopfdaten für KML-Dateien
        $content = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
	<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
		<Folder>';
        foreach ($rowArray as $row) {
            $content .= makePlaceEntryKML($row);
        }
        // Fußdaten für KML-Dateien
        $content .= '
		</Folder>
	</kml>';
    }
    // Abspeichern der im String $content zwischengespeicherten Daten in einer Datei im Projektordner
    $fileName = $folderName . '/printingPlaces.' . $ending;
    $datei = fopen($fileName, "w");
    fwrite($datei, $content, 30000000);
    fclose($datei);
}