Package ch.epfl.lbd.io.readers

Examples of ch.epfl.lbd.io.readers.ShapeFileReader


public class ShapeFileCoordinatesInverter{

  public static void convert(String input, String output) throws Exception{
    //load shp file
    ShapeFileReader reader = null;
    reader = new ShapeFileReader(new File(input));
    reader.open();
   
    //get all geometries and invert LAT,LNG coordinates
    Geometry[] geometries = reader.readAll();
   
    for(int i = 0 ; i < geometries.length ; i++ ){
      Coordinate[] coordinates = geometries[i].getCoordinates();
      for(int j = 0 ; j < coordinates.length ; j++ ){
        double x = coordinates[j].x;
        coordinates[j].x = coordinates[j].y;
        coordinates[j].y = x;
      }
    }
   
   
    //save shp file
    ShapeFileWriter writer = null;
    writer = new ShapeFileWriter(output);
    writer.open();
    writer.write(geometries);
   
    //closing Readers, Writers
    reader.close();
    writer.close();
  }
View Full Code Here


import ch.epfl.lbd.io.readers.ShapeFileReader;

public class TestShpFileReader extends Tester {
   @Override
   public void run(){
     ShapeFileReader reader = null;
     try{
       reader = new ShapeFileReader(new File("src/assets/shp/region.shp"));
     }
     catch (Exception e) {
      e.printStackTrace();
    }
    reader.open();
    Geometry[] geometries = reader.read();
    Assert.assertEquals(1, geometries.length);
    reader.close();
   }
View Full Code Here

       catch (Exception e) {
        e.printStackTrace();
      }
      writer.open();
     
      ShapeFileReader reader = null;
      try{
        reader = new ShapeFileReader(new File("src/assets/shp/region.shp"));
       }
       catch (Exception e) {
        e.printStackTrace();
      }
      reader.open();
      Geometry[] geometries = reader.readAll();

      Assert.assertEquals(3, geometries.length);
      writer.write(geometries);
      reader.close();
      writer.close();
    }
View Full Code Here

TOP

Related Classes of ch.epfl.lbd.io.readers.ShapeFileReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.