/// <summary> /// Opens the StreamWriter and writes the Header. Throws an exception, if /// the file couldn't be opened. /// </summary> internal void OpenFile() { try { geoJsonFile = new StreamWriter(filePath); geoJsonFile.Write(GeoJsonFormatter.GetHeader()); } catch (Exception) { Console.WriteLine("Opening File failed!"); } }
/// <summary> /// Writes a List of Adresses to the defined output file. /// </summary> /// <param name="geoCodedAdresses">A List of geocoded instances of the class Adress</param> internal void ExportAdressesToOutput(List <Adress> geoCodedAdresses) { // The first entry in the Adress-List. Adress first = geoCodedAdresses.First(); foreach (Adress geoCodedAdress in geoCodedAdresses) { // Write the feature separator to the file if it's not the first feature if (!geoCodedAdress.Equals(first)) { geoJsonFile.Write(GeoJsonFormatter.GetFeatureEnd()); } this.WriteAdressToFile(geoCodedAdress); } }
/// <summary> /// Writes a geolocatedAdress to the export file as a geoJson-Point. /// </summary> /// <param name="adress"></param> private void WriteAdressToFile(Adress adress) { string geoJsonPoint = GeoJsonFormatter.GetGeoJsonAdress(adress); geoJsonFile.Write(geoJsonPoint); }
/// <summary> /// Writes the footer to the geoJson file and closes it. /// </summary> internal void CloseFile() { geoJsonFile.Write(GeoJsonFormatter.GetFooter()); geoJsonFile.Close(); }