├── .gitignore ├── .travis.yml ├── Licence-en.html ├── Licence-fr.html ├── README.md ├── lib └── native_libraries │ ├── linux-amd64 │ ├── j3dcore-ogl.so │ └── libj3dcore-ogl.so │ ├── linux-i386 │ ├── libj3dcore-ogl-cg.so │ └── libj3dcore-ogl.so │ ├── windows-amd64 │ └── j3dcore-ogl.dll │ └── windows-i586 │ ├── j3dcore-d3d.dll │ ├── j3dcore-ogl-cg.dll │ ├── j3dcore-ogl-chk.dll │ ├── j3dcore-ogl.dll │ └── tetrahedrize.dll ├── pom.xml ├── readme_images └── simParc.png └── src ├── main ├── java │ └── fr │ │ └── ign │ │ └── cogit │ │ └── simplu3d │ │ ├── exec │ │ ├── BasicSimulator.java │ │ └── IglooSimulator.java │ │ ├── experiments │ │ ├── morpho │ │ │ └── Compacity.java │ │ └── openmole │ │ │ └── diversity │ │ │ ├── EntropyCalculation.java │ │ │ ├── EntropyIndicator.java │ │ │ └── ProfileMoran.java │ │ ├── io │ │ ├── postgis │ │ │ ├── ExperimentationPostGIS.java │ │ │ ├── ParametersPostgis.java │ │ │ ├── ParametersToPostGRES.java │ │ │ └── SaveEnergyPostGIS.java │ │ └── shapefile │ │ │ └── SaveGeneratedObjects.java │ │ ├── rjmcmc │ │ ├── cuboid │ │ │ ├── builder │ │ │ │ ├── CuboidBuilder.java │ │ │ │ ├── ParallelCuboidBuilder.java │ │ │ │ ├── SimpleCuboidBuilder.java │ │ │ │ ├── SimpleCuboidBuilder2.java │ │ │ │ └── mix │ │ │ │ │ ├── CuboidAbstractSimpleBuildingBuilder.java │ │ │ │ │ ├── ParallelCuboidAbstractSimpleBuildingBuilder.java │ │ │ │ │ ├── ParallelRightTrapezoidAbstractSimpleBuildingBuilder2.java │ │ │ │ │ ├── SimpleCuboidAbstractSimpleBuildingBuilder.java │ │ │ │ │ └── SimpleCuboidAbstractSimpleBuildingBuilder2.java │ │ │ ├── geometry │ │ │ │ ├── impl │ │ │ │ │ ├── AbstractSimpleBuilding.java │ │ │ │ │ ├── Cuboid.java │ │ │ │ │ ├── FastBuildingPart.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── loader │ │ │ │ │ ├── LoaderCuboid.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ └── simple │ │ │ │ │ ├── AbstractParallelCuboid.java │ │ │ │ │ ├── ParallelCuboid.java │ │ │ │ │ ├── ParallelCuboid2.java │ │ │ │ │ ├── SimpleCuboid.java │ │ │ │ │ └── SimpleCuboid2.java │ │ │ ├── optimizer │ │ │ │ ├── cuboid │ │ │ │ │ ├── BasicCuboidOptimizer.java │ │ │ │ │ ├── OptimisedBuildingsCuboidDirectRejectionNoVisitor.java │ │ │ │ │ ├── OptimisedBuildingsCuboidFinalDirectRejection.java │ │ │ │ │ ├── OptimisedBuildingsCuboidFinalDirectRejectionParallelTempering.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ └── paralellcuboid │ │ │ │ │ └── ParallelCuboidOptimizer.java │ │ │ ├── package-info.java │ │ │ ├── sampler │ │ │ │ ├── MixAbstractBuildingSampler.java │ │ │ │ └── MixCuboidSampler.java │ │ │ └── transformation │ │ │ │ ├── ChangeHeight.java │ │ │ │ ├── ChangeLength.java │ │ │ │ ├── ChangeWidth.java │ │ │ │ ├── MoveCuboid.java │ │ │ │ ├── RotateCuboid.java │ │ │ │ ├── birth │ │ │ │ ├── ParallelCuboidTransform.java │ │ │ │ ├── ParallelPolygonTransform.java │ │ │ │ ├── TransformToSurface.java │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ └── parallelCuboid │ │ │ │ └── MoveParallelCuboid.java │ │ ├── generic │ │ │ ├── energy │ │ │ │ ├── CompacityCollectionEnergy.java │ │ │ │ ├── DifferenceVolumeUnaryEnergy.java │ │ │ │ ├── IntersectionVolumeBinaryEnergy.java │ │ │ │ └── VolumeUnaryEnergy.java │ │ │ ├── object │ │ │ │ └── ISimPLU3DPrimitive.java │ │ │ ├── optimizer │ │ │ │ ├── DefaultSimPLU3DOptimizer.java │ │ │ │ └── ISimPLU3DOptimizer.java │ │ │ ├── predicate │ │ │ │ └── SamplePredicate.java │ │ │ ├── sampler │ │ │ │ └── GreenSamplerBlockTemperature.java │ │ │ ├── transform │ │ │ │ └── SimplePolygonTransform.java │ │ │ └── visitor │ │ │ │ ├── CSVendStats.java │ │ │ │ ├── CSVvisitor.java │ │ │ │ ├── CountVisitor.java │ │ │ │ ├── FilmVisitor.java │ │ │ │ ├── PrepareVisitors.java │ │ │ │ ├── ShapefileVisitor.java │ │ │ │ ├── StatsVisitor.java │ │ │ │ ├── ViewerVisitor.java │ │ │ │ └── package-info.java │ │ ├── paramshp │ │ │ ├── builder │ │ │ │ ├── CuboidRoofedBuilder.java │ │ │ │ └── LBuildingWithRoofBuilder.java │ │ │ ├── geometry │ │ │ │ └── impl │ │ │ │ │ ├── AbstractParallelCuboidRoofed.java │ │ │ │ │ ├── CuboidRoofed.java │ │ │ │ │ ├── LBuildingWithRoof.java │ │ │ │ │ ├── ParallelCuboidRoofed.java │ │ │ │ │ └── ParallelCuboidRoofed2.java │ │ │ ├── optimizer │ │ │ │ ├── OptimisedLShapeDirectRejection.java │ │ │ │ └── OptimisedRCuboidDirectRejection.java │ │ │ └── transform │ │ │ │ ├── MoveLShapeBuilding.java │ │ │ │ └── MoveRCuboid.java │ │ └── trapezoid │ │ │ ├── builder │ │ │ ├── ParallelRightTrapezoidBuilder.java │ │ │ ├── ParallelRightTrapezoidBuilder2.java │ │ │ └── SimpleRightTrapezoidBuilder.java │ │ │ ├── geometry │ │ │ ├── ParallelTrapezoid.java │ │ │ ├── ParallelTrapezoid2.java │ │ │ └── RightTrapezoid.java │ │ │ ├── optimizer │ │ │ └── OptimisedParallelTrapezoidFinalDirectRejection.java │ │ │ ├── transform │ │ │ └── ParallelTrapezoidTransform.java │ │ │ └── transformation │ │ │ ├── MoveParallelRightTrapezoid.java │ │ │ └── RotateTrapezoid.java │ │ └── util │ │ ├── CuboidGroupCreation.java │ │ ├── SimpluParameters.java │ │ ├── SimpluParametersJSON.java │ │ ├── SimpluParametersPostgis.java │ │ ├── convert │ │ ├── ExportAsFeatureCollection.java │ │ └── TransformXMLToJSON.java │ │ ├── distribution │ │ ├── Initialize.java │ │ └── ZonePackager.java │ │ ├── merge │ │ ├── MergeCuboid.java │ │ └── SDPCalc.java │ │ └── regulation │ │ └── DefaultAbstractPredicate.java └── resources │ ├── fr │ └── ign │ │ └── cogit │ │ └── simplu3d │ │ ├── data │ │ ├── DOC_URBA.dbf │ │ ├── DOC_URBA.shp │ │ ├── DOC_URBA.shx │ │ ├── MNT.asc │ │ ├── MNT_BD3D.asc.aux.xml │ │ ├── PRESCRIPTION_LIN.dbf │ │ ├── PRESCRIPTION_LIN.prj │ │ ├── PRESCRIPTION_LIN.qpj │ │ ├── PRESCRIPTION_LIN.shp │ │ ├── PRESCRIPTION_LIN.shx │ │ ├── ZONE_URBA.dbf │ │ ├── ZONE_URBA.shp │ │ ├── ZONE_URBA.shx │ │ ├── background3D.png │ │ ├── bati.dbf │ │ ├── bati.prj │ │ ├── bati.shp │ │ ├── bati.shx │ │ ├── parcelle.dbf │ │ ├── parcelle.prj │ │ ├── parcelle.shp │ │ ├── parcelle.shx │ │ ├── parcelleIgloo.dbf │ │ ├── parcelleIgloo.prj │ │ ├── parcelleIgloo.shp │ │ ├── parcelleIgloo.shx │ │ ├── route.dbf │ │ ├── route.prj │ │ ├── route.shp │ │ └── route.shx │ │ ├── data2 │ │ ├── Coord.txt │ │ ├── MNT_BD3D.asc │ │ ├── Merged.asc │ │ ├── Merged.asc.aux.xml │ │ ├── MergedSmall.asc │ │ ├── MergedSmall.asc.aux.xml │ │ ├── background3D.png │ │ ├── background3D.tiff │ │ ├── bati.dbf │ │ ├── bati.prj │ │ ├── bati.shp │ │ ├── bati.shx │ │ ├── decoup.dbf │ │ ├── decoup.prj │ │ ├── decoup.qpj │ │ ├── decoup.shp │ │ ├── decoup.shx │ │ ├── env3D │ │ ├── mergedout.asc │ │ ├── mergedout.asc.aux.xml │ │ ├── parcelle.dbf │ │ ├── parcelle.prj │ │ ├── parcelle.shp │ │ ├── parcelle.shx │ │ ├── route.dbf │ │ ├── route.prj │ │ ├── route.shp │ │ ├── route.shx │ │ ├── shapeModif.dbf │ │ ├── shapeModif.shp │ │ ├── shapeModif.shx │ │ ├── sqlmnt.sql │ │ ├── zonage.dbf │ │ ├── zonage.prj │ │ ├── zonage.shp │ │ └── zonage.shx │ │ ├── schema │ │ └── schema.xmi │ │ ├── simul │ │ ├── simul.dbf │ │ ├── simul.prj │ │ ├── simul.shp │ │ └── simul.shx │ │ └── sql │ │ └── Creation_BDD.sql │ ├── log4j.properties │ └── scenario │ ├── building_parameters_project_expthese_3.json │ ├── parameters_iauidf.json │ ├── parameters_iauidf_test.json │ ├── paramsIgloo.json │ ├── scenariotest.json │ └── tableParameter.sql └── test ├── java └── fr │ └── ign │ └── cogit │ └── simplu3d │ └── test │ ├── rjmcmc │ ├── cuboid │ │ └── transformation │ │ │ ├── RotateCuboid2Test.java │ │ │ └── birth │ │ │ ├── InversionBirth.java │ │ │ ├── ParallelPolygonTransformTest.java │ │ │ ├── SimplePolygonTransformTest.java │ │ │ └── TransformToSurfaceTest.java │ ├── paramshapes │ │ ├── TestCuboidRoofed.java │ │ └── TestParamShape.java │ └── trapezoid │ │ ├── TestParallelRightTrapezoidSampler.java │ │ ├── TestParallelRightTrapezoidSampler2.java │ │ └── TestRightTrapezoidSampler.java │ ├── sdpcalc │ └── SDPCalcTest.java │ └── simulator │ └── SimulatorTest.java └── resources ├── native_libraries ├── windows-amd64 │ ├── j3dcore-ogl.dll │ └── tetrahedrize.dll └── windows-i586 │ ├── j3dcore-d3d.dll │ ├── j3dcore-ogl-cg.dll │ ├── j3dcore-ogl-chk.dll │ ├── j3dcore-ogl.dll │ ├── test │ ├── cg.dll │ ├── cgD3D10.dll │ ├── cgD3D8.dll │ ├── cgD3D9.dll │ ├── cgGL.dll │ └── glut32.dll │ ├── tetrahedrize.dll │ └── trianguledll.dll └── scenario └── scenariotest.json /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | *.classpath 8 | *.project 9 | *.settings 10 | /.idea/ 11 | /log/ 12 | /log4j.log 13 | /simplu3d.iml 14 | **~ 15 | log4j.log 16 | hs_err_pid* 17 | .Rhistory 18 | /bin/ 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: java 3 | jdk: 4 | - openjdk8 5 | 6 | install: true 7 | 8 | env: 9 | - maven.wagon.http.ssl.insecure=true maven.wagon.http.ssl.allowall=true maven.wagon.http.ssl.ignore.validity.dates=true 10 | 11 | script: 12 | - mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true 13 | -------------------------------------------------------------------------------- /Licence-en.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/Licence-en.html -------------------------------------------------------------------------------- /Licence-fr.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/Licence-fr.html -------------------------------------------------------------------------------- /lib/native_libraries/linux-amd64/j3dcore-ogl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/linux-amd64/j3dcore-ogl.so -------------------------------------------------------------------------------- /lib/native_libraries/linux-amd64/libj3dcore-ogl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/linux-amd64/libj3dcore-ogl.so -------------------------------------------------------------------------------- /lib/native_libraries/linux-i386/libj3dcore-ogl-cg.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/linux-i386/libj3dcore-ogl-cg.so -------------------------------------------------------------------------------- /lib/native_libraries/linux-i386/libj3dcore-ogl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/linux-i386/libj3dcore-ogl.so -------------------------------------------------------------------------------- /lib/native_libraries/windows-amd64/j3dcore-ogl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/windows-amd64/j3dcore-ogl.dll -------------------------------------------------------------------------------- /lib/native_libraries/windows-i586/j3dcore-d3d.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/windows-i586/j3dcore-d3d.dll -------------------------------------------------------------------------------- /lib/native_libraries/windows-i586/j3dcore-ogl-cg.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/windows-i586/j3dcore-ogl-cg.dll -------------------------------------------------------------------------------- /lib/native_libraries/windows-i586/j3dcore-ogl-chk.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/windows-i586/j3dcore-ogl-chk.dll -------------------------------------------------------------------------------- /lib/native_libraries/windows-i586/j3dcore-ogl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/windows-i586/j3dcore-ogl.dll -------------------------------------------------------------------------------- /lib/native_libraries/windows-i586/tetrahedrize.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/lib/native_libraries/windows-i586/tetrahedrize.dll -------------------------------------------------------------------------------- /readme_images/simParc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/readme_images/simParc.png -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/exec/BasicSimulator.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.exec; 2 | 3 | import java.io.File; 4 | 5 | import fr.ign.cogit.geoxygene.api.feature.IFeature; 6 | import fr.ign.cogit.geoxygene.api.feature.IFeatureCollection; 7 | import fr.ign.cogit.geoxygene.contrib.cartetopo.CarteTopo; 8 | import fr.ign.cogit.simplu3d.demo.DemoEnvironmentProvider; 9 | import fr.ign.cogit.simplu3d.io.nonStructDatabase.shp.LoaderSHP; 10 | import fr.ign.cogit.simplu3d.io.shapefile.SaveGeneratedObjects; 11 | import fr.ign.cogit.simplu3d.model.BasicPropertyUnit; 12 | import fr.ign.cogit.simplu3d.model.Environnement; 13 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 14 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.optimizer.cuboid.OptimisedBuildingsCuboidFinalDirectRejection; 15 | import fr.ign.cogit.simplu3d.rjmcmc.generic.predicate.SamplePredicate; 16 | import fr.ign.cogit.simplu3d.util.SimpluParameters; 17 | import fr.ign.cogit.simplu3d.util.SimpluParametersJSON; 18 | import fr.ign.cogit.simplu3d.util.merge.MergeCuboid; 19 | import fr.ign.cogit.simplu3d.util.merge.SDPCalc; 20 | import fr.ign.mpp.configuration.BirthDeathModification; 21 | import fr.ign.mpp.configuration.GraphConfiguration; 22 | 23 | /** 24 | * 25 | * This software is released under the licence CeCILL 26 | * 27 | * see LICENSE.TXT 28 | * 29 | * see http://www.cecill.info/ 30 | * 31 | * 32 | * 33 | * copyright IGN 34 | * 35 | * @author Brasebin Mickaël 36 | * 37 | * @version 1.0 38 | * 39 | * Simulateur standard 40 | * 41 | * 42 | */ 43 | public class BasicSimulator { 44 | 45 | 46 | public static void main(String[] args) throws Exception { 47 | 48 | // Loading of configuration file that contains sampling space 49 | // information and simulated annealing configuration 50 | String folderName = BasicSimulator.class.getClassLoader().getResource("scenario/").getPath(); 51 | 52 | String fileName = "building_parameters_project_expthese_3.json"; 53 | SimpluParameters p = new SimpluParametersJSON(new File(folderName + fileName)); 54 | 55 | // Load default environment (data are in resource directory) 56 | Environnement env = LoaderSHP.loadNoDTM(new File( 57 | DemoEnvironmentProvider.class.getClassLoader().getResource("fr/ign/cogit/simplu3d/data/").getPath())); 58 | 59 | for(int i=0; i<80; i++) { 60 | System.out.println("------------------------------"); 61 | for(BasicPropertyUnit bPU: env.getBpU()) { 62 | 63 | // Select a parcel on which generation is proceeded 64 | //BasicPropertyUnit bPU = env.getBpU().get(17); 65 | 66 | // Instantiation of the sampler 67 | OptimisedBuildingsCuboidFinalDirectRejection oCB = new OptimisedBuildingsCuboidFinalDirectRejection(); 68 | 69 | // Rules parameters.8 70 | // Distance to road 71 | double distReculVoirie = 1; 72 | // Distance to bottom of the parcel 73 | double distReculFond = 0; 74 | // Distance to lateral parcel limits 75 | double distReculLat = 2; 76 | // Distance between two buildings of a parcel 77 | double distanceInterBati = 0; 78 | // Maximal ratio built area 79 | double maximalCES = 0.9; 80 | 81 | // Instantiation of the rule checker 82 | SamplePredicate, BirthDeathModification> pred = new SamplePredicate<>( 83 | bPU, distReculVoirie, distReculFond, distReculLat, distanceInterBati, maximalCES); 84 | 85 | // Run of the optimisation on a parcel with the predicate 86 | GraphConfiguration cc = oCB.process(bPU, p, env, 1, pred); 87 | 88 | 89 | //System.out.println("dans la parcelle" + bPU.getId()+ "il y a" + cc.size()+ "cuboides" ); 90 | 91 | 92 | 93 | 94 | 95 | // Writting the output 96 | String pathCourant = p.get("result").toString() + "out_"+ bPU.getId() +".shp"; 97 | SaveGeneratedObjects.saveShapefile(pathCourant, cc, bPU.getId(), 0); 98 | 99 | MergeCuboid recal = new MergeCuboid(); 100 | 101 | IFeatureCollection fus = recal.mergeFromShapefile(pathCourant, 0.0); 102 | // System.out.println("Surface" + recal.getSurface()); 103 | // System.out.println("Energie" + cc.getEnergy()); 104 | // System.out.println("ratio" + cc.getEnergy()/recal.getSurface()); 105 | 106 | SDPCalc sdpcalc = new SDPCalc(); 107 | 108 | Double sdp = sdpcalc.process(pathCourant); 109 | 110 | System.out.println( bPU.getId()+","+ cc.size()+","+recal.getSurface()+","+cc.getEnergy()+","+sdp); 111 | 112 | 113 | 114 | } 115 | } 116 | System.out.println("that's all folks"); 117 | } 118 | 119 | 120 | 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/experiments/openmole/diversity/ProfileMoran.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.experiments.openmole.diversity; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | 8 | 9 | public class ProfileMoran { 10 | 11 | double moranProfileFinal = -2.0; 12 | 13 | public static void main(String[] args) { 14 | 15 | int n = 1000; 16 | Random randomnum = new Random(); 17 | ArrayList test = new ArrayList(); 18 | System.out.println("liste taille" + test.size()); 19 | 20 | for (int i = 0; i < n; i++) { 21 | 22 | // if (randomnum.nextInt(2)>0) { 23 | // //if(i<25 || i >= 75 ){ 24 | // test.add(10.); 25 | // } 26 | // else{ 27 | // test.add(0.); 28 | // } 29 | test.add(0.0); 30 | 31 | } 32 | System.out.println(test.toString()); 33 | ProfileMoran p = new ProfileMoran(); 34 | p.calculate(test); 35 | System.out.println(p.getMoranProfileFinal()); 36 | 37 | }//main 38 | 39 | 40 | // distance between i and j on curve of length dmax (discrete) 41 | 42 | public int distanceCurvi (int i , int j, int dmax){ 43 | return Math.min(Math.abs(j - i), i + (dmax - j)); 44 | 45 | } 46 | 47 | public void calculate(List heights) { 48 | 49 | int nbpts = heights.size(); 50 | 51 | double sum_weights = 0; 52 | for (int i = 0; i < nbpts; i++) { 53 | for (int j = 0; j < nbpts; j++) { 54 | if (i != j) { 55 | sum_weights += (1.0 / distanceCurvi(i, j, nbpts)); 56 | } 57 | } 58 | } 59 | 60 | double htot = 0; 61 | for (int i = 0; i < heights.size(); i++) { 62 | htot = htot + heights.get(i); 63 | } 64 | 65 | double hmean = htot / nbpts; 66 | 67 | double numer = 0; 68 | double denom = 0; 69 | double moran = 0; 70 | for (int i = 0; i < nbpts; i++) { 71 | for (int j = 0; j < nbpts; j++) { 72 | if (i != j) { 73 | numer += (heights.get(i) - hmean) * (heights.get(j) - hmean) 74 | / distanceCurvi(i, j, nbpts); 75 | // denom += ((energy_parcels.get(i) - mean_energy) * 76 | // (energy_parcels.get(i) - mean_energy)); 77 | 78 | } 79 | } 80 | denom += ((heights.get(i) - hmean) * (heights.get(i) - hmean)); 81 | } 82 | moran = numer / denom; 83 | 84 | moran *= (nbpts / sum_weights); 85 | 86 | this.moranProfileFinal = moran; 87 | 88 | // moran should be between -1 and 1 89 | if (moranProfileFinal > 1 || moranProfileFinal < -1) { 90 | System.out.println( 91 | "# erreur dans le calcul de moran :" + this.moranProfileFinal); 92 | } 93 | 94 | } 95 | // System.out.println("moran de la zone " + moran); 96 | 97 | public double getMoranProfileFinal() { 98 | return moranProfileFinal; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/io/postgis/ExperimentationPostGIS.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.io.postgis; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.sql.Statement; 8 | 9 | import org.apache.logging.log4j.LogManager; 10 | import org.apache.logging.log4j.Logger; 11 | 12 | import fr.ign.parameters.Parameters; 13 | /** 14 | * 15 | * This software is released under the licence CeCILL 16 | * 17 | * see LICENSE.TXT 18 | * 19 | * see http://www.cecill.info/ 20 | * 21 | * 22 | * 23 | * copyright IGN 24 | * 25 | * @author Brasebin Mickaël 26 | * 27 | * @version 1.0 28 | **/ 29 | public class ExperimentationPostGIS extends Parameters { 30 | 31 | public final static String EXPERIMENTATION_TABLE = "experimentation"; 32 | public final static String EXPERIMENTATION_ID = "idexp"; 33 | public final static String EXPERIMENTATION_ID_PARAM = "idparam"; 34 | private ResultSet rs; 35 | 36 | private Logger log = LogManager.getLogger(ParametersPostgis.class); 37 | 38 | private int id; 39 | 40 | private String url, user, pw; 41 | 42 | public ExperimentationPostGIS(String host, String port, String database, String user, String pw, int id) throws SQLException { 43 | this.id = id; 44 | this.user = user; 45 | this.pw = pw; 46 | url = "jdbc:postgresql://" + host + ":" + port + "/" + database; 47 | Connection conn = DriverManager.getConnection(url, user, pw); 48 | Statement s = conn.createStatement(); 49 | String sql = "Select * from " + EXPERIMENTATION_TABLE + " where " + EXPERIMENTATION_ID + " =" + id ; 50 | rs = s.executeQuery(sql); 51 | System.out.println(sql); 52 | boolean next = rs.next(); 53 | if (!next) { 54 | log.error("No parameters line found"); 55 | System.exit(1); 56 | } 57 | conn.close(); 58 | } 59 | 60 | public boolean setProcessed() throws SQLException { 61 | Connection conn = DriverManager.getConnection(url, user, pw); 62 | Statement s = conn.createStatement(); 63 | String sql = "UPDATE " + EXPERIMENTATION_TABLE + " set isprocessed = 't' where " + EXPERIMENTATION_ID + " = " + id; 64 | boolean isOk = s.execute(sql); 65 | conn.close(); 66 | return isOk; 67 | } 68 | 69 | public Object get(String key) { 70 | if (rs != null) { 71 | try { 72 | return rs.getObject(key); 73 | } catch (SQLException e) { 74 | e.printStackTrace(); 75 | } 76 | } 77 | return null; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/io/postgis/ParametersPostgis.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.io.postgis; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.sql.Statement; 8 | 9 | import org.apache.logging.log4j.LogManager; 10 | import org.apache.logging.log4j.Logger; 11 | 12 | import fr.ign.parameters.Parameters; 13 | 14 | 15 | /** 16 | * 17 | * This software is released under the licence CeCILL 18 | * 19 | * see LICENSE.TXT 20 | * 21 | * see http://www.cecill.info/ 22 | * 23 | * 24 | * 25 | * copyright IGN 26 | * 27 | * @author Brasebin Mickaël 28 | * 29 | * @version 1.0 30 | **/ 31 | public class ParametersPostgis extends Parameters { 32 | 33 | public final static String PARAMETERS_TABLE = "parameters"; 34 | public final static String PARAMETERS_ID = "id"; 35 | private ResultSet rs; 36 | 37 | private Logger log = LogManager.getLogger(ParametersPostgis.class); 38 | 39 | public ParametersPostgis(String host, String port, String database, String user, String pw, int id) throws SQLException { 40 | String url = "jdbc:postgresql://" + host + ":" + port + "/" + database; 41 | Connection conn = DriverManager.getConnection(url, user, pw); 42 | Statement s = conn.createStatement(); 43 | String sql = "Select * from " + PARAMETERS_TABLE + " where "+PARAMETERS_ID+" =" + id; 44 | rs = s.executeQuery(sql); 45 | boolean next = rs.next(); 46 | if (!next) { 47 | log.error("No parameters line found"); 48 | System.exit(1); 49 | } 50 | conn.close(); 51 | } 52 | 53 | @Override 54 | public Object get(String key) { 55 | if (entry != null) { 56 | try { 57 | return rs.getObject(key); 58 | } catch (SQLException e) { 59 | e.printStackTrace(); 60 | } 61 | } 62 | return null; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/io/postgis/ParametersToPostGRES.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.io.postgis; 2 | 3 | import java.io.File; 4 | import java.sql.Connection; 5 | import java.sql.DriverManager; 6 | import java.sql.Statement; 7 | 8 | import fr.ign.cogit.simplu3d.exec.BasicSimulator; 9 | import fr.ign.cogit.simplu3d.util.SimpluParameters; 10 | import fr.ign.cogit.simplu3d.util.SimpluParametersJSON; 11 | 12 | /** 13 | * 14 | * This software is released under the licence CeCILL 15 | * 16 | * see LICENSE.TXT 17 | * 18 | * see http://www.cecill.info/ 19 | * 20 | * 21 | * 22 | * copyright IGN 23 | * 24 | * @author Brasebin Mickaël 25 | * 26 | * @version 1.0 27 | * 28 | * Classe pour charger dans PostGIS les paramètres xml des fichiers de 29 | * configuration. Le script tableParameter.sql doit être exécuté au préalable 30 | * pour crééer la table parameters. 31 | * 32 | * 33 | */ 34 | public class ParametersToPostGRES { 35 | 36 | 37 | /** 38 | * Test the store of json parameters into a postgres database 39 | * @param args not used here 40 | * @throws Exception Exception in database connexion 41 | */ 42 | public static void main(String[] args) throws Exception { 43 | String folderName = BasicSimulator.class.getClassLoader().getResource("scenario/").getPath(); 44 | 45 | String fileName = "building_parameters_project_expthese_3.json"; 46 | 47 | SimpluParameters p = new SimpluParametersJSON(new File(folderName + fileName)); 48 | 49 | String host = "localhost"; 50 | String port = "5432"; 51 | String database = "gtru"; 52 | String user = "postgres"; 53 | String pw = "postgres"; 54 | 55 | String sql = "Insert into parameters Values (" + 56 | 57 | p.getDouble("energy") + ", " + p.getDouble("ponderation_volume") + ", " 58 | + p.getDouble("ponderation_difference_ext") + ", " 59 | + p.getDouble("ponderation_volume_inter") + ", " 60 | + p.getDouble("mindim") + ", " + p.getDouble("maxdim") + ", " 61 | + p.getDouble("minheight") + ", " + p.getDouble("maxheight") + ", " 62 | + p.getDouble("pbirth") + ", " + p.getDouble("pdeath") + ", " 63 | + p.getDouble("amplitudeMaxDim") + ", " 64 | + p.getDouble("amplitudeHeight") + ", " + p.getDouble("amplitudeMove") 65 | + ", " + p.getDouble("amplitudeRotate") + ", " + p.getDouble("temp") 66 | + ", " + p.getDouble("deccoef") + ", " 67 | + p.getString("end_test_type") + ", " + p.getInteger("absolute_nb_iter") 68 | + ", " + p.getInteger("relative_nb_iter") + ", " + p.getDouble("delta") 69 | + ", " + p.getDouble("poisson") + 70 | ");"; 71 | 72 | String url = "jdbc:postgresql://" + host + ":" + port + "/" + database; 73 | Connection conn = DriverManager.getConnection(url, user, pw); 74 | Statement s = conn.createStatement(); 75 | s.execute(sql); 76 | conn.close(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/io/postgis/SaveEnergyPostGIS.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.io.postgis; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | import java.sql.Statement; 7 | /** 8 | * 9 | * This software is released under the licence CeCILL 10 | * 11 | * see LICENSE.TXT 12 | * 13 | * see http://www.cecill.info/ 14 | * 15 | * 16 | * 17 | * copyright IGN 18 | * 19 | * @author Brasebin Mickaël 20 | * 21 | * @version 1.0 22 | **/ 23 | public class SaveEnergyPostGIS { 24 | 25 | public final static String TABLE_SAVE_ENERGY = "volgeneratedbyparcel"; 26 | 27 | public static void save(String host, String port, String database, 28 | String user, String pw, int id_exp, int id_parcelle, int run, double energy) 29 | throws SQLException { 30 | 31 | String url = "jdbc:postgresql://" + host + ":" + port + "/" + database; 32 | 33 | Connection conn = DriverManager.getConnection(url, user, pw); 34 | 35 | Statement s = conn.createStatement(); 36 | 37 | String sql = "insert into " + TABLE_SAVE_ENERGY + "(id_exp, id_parcelle, run, energy) VALUES ( " + id_exp 38 | + "," + id_parcelle + "," +run+ ","+ energy + ")"; 39 | 40 | System.out.println(sql); 41 | s.execute(sql); 42 | 43 | conn.close(); 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/io/shapefile/SaveGeneratedObjects.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.io.shapefile; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.Statement; 6 | 7 | import org.apache.logging.log4j.LogManager; 8 | import org.apache.logging.log4j.Logger; 9 | import org.geotools.referencing.CRS; 10 | import org.opengis.referencing.FactoryException; 11 | import org.opengis.referencing.NoSuchAuthorityCodeException; 12 | 13 | import fr.ign.cogit.geoxygene.sig3d.Messages; 14 | import fr.ign.cogit.geoxygene.util.conversion.ShapefileWriter; 15 | import fr.ign.cogit.geoxygene.util.conversion.WktGeOxygene; 16 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.AbstractSimpleBuilding; 17 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 18 | import fr.ign.cogit.simplu3d.util.convert.ExportAsFeatureCollection; 19 | import fr.ign.mpp.configuration.GraphConfiguration; 20 | import fr.ign.mpp.configuration.GraphVertex; 21 | 22 | /** 23 | * 24 | * This software is released under the licence CeCILL 25 | * 26 | * see LICENSE.TXT 27 | * 28 | * see http://www.cecill.info/ 29 | * 30 | * 31 | * 32 | * copyright IGN 33 | * 34 | * @author Brasebin Mickaël 35 | * 36 | * @version 1.0 37 | **/ 38 | public class SaveGeneratedObjects { 39 | 40 | private final static Logger logger = LogManager.getLogger(SaveGeneratedObjects.class.getName()); 41 | 42 | public final static String SRID = "2154"; 43 | 44 | public static final String TABLE_GENERATED_BUILDING = "generatedbuildings"; 45 | 46 | public static boolean saveShapefile(String path, GraphConfiguration cc, int idParcelle, long seed) { 47 | ExportAsFeatureCollection exporter = new ExportAsFeatureCollection(cc, idParcelle); 48 | try { 49 | ShapefileWriter.write(exporter.getFeatureCollection(), path, CRS.decode("EPSG:"+SRID)); 50 | } catch (NoSuchAuthorityCodeException e) { 51 | // TODO Auto-generated catch block 52 | e.printStackTrace(); 53 | } catch (FactoryException e) { 54 | // TODO Auto-generated catch block 55 | e.printStackTrace(); 56 | } 57 | return true; 58 | } 59 | 60 | public static boolean save(String host, String port, String database, String user, String pw, GraphConfiguration cc, 61 | int idExperiment, int idParcelle, long seed) { 62 | try { 63 | // Création de l'URL de chargement 64 | String url = "jdbc:postgresql://" + host + ":" + port + "/" + database; 65 | SaveGeneratedObjects.logger.info(Messages.getString("PostGIS.Try") + url); 66 | // Connexion 67 | Connection conn = DriverManager.getConnection(url, user, pw); 68 | Statement s = conn.createStatement(); 69 | for (GraphVertex v : cc.getGraph().vertexSet()) { 70 | double longueur = Math.max(v.getValue().length, v.getValue().width); 71 | double largeur = Math.min(v.getValue().length, v.getValue().width); 72 | double hauteur = v.getValue().height; 73 | double orientation = v.getValue().orientation; 74 | String geomWKT = "ST_GeomFromText('" + WktGeOxygene.makeWkt(v.getValue().generated3DGeom()) + "'," + SRID + ")"; 75 | String sql = "Insert into " + TABLE_GENERATED_BUILDING 76 | + "(idparcelle,largeur,longueur,hauteur,orientation,idexperiment, the_geom, seed) values (" + idParcelle + "," + largeur + "," 77 | + longueur + "," + hauteur + "," + orientation + "," + idExperiment + "," + geomWKT + "," + seed + ")"; 78 | System.out.println(sql); 79 | s.addBatch(sql); 80 | } 81 | s.executeBatch(); 82 | conn.close(); 83 | } catch (Exception e) { 84 | e.printStackTrace(); 85 | return false; 86 | } 87 | return true; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/builder/CuboidBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.builder; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 4 | import fr.ign.mpp.kernel.ObjectBuilder; 5 | 6 | 7 | /** 8 | * This software is released under the licence CeCILL 9 | * 10 | * see LICENSE.TXT 11 | * 12 | * see http://www.cecill.info/ 13 | * 14 | * 15 | * Basic class for Cuboid Sampler 16 | * 17 | * @author MBrasebin 18 | * 19 | */ 20 | public class CuboidBuilder implements ObjectBuilder{ 21 | @Override 22 | public int size() { 23 | return 6; 24 | } 25 | 26 | @Override 27 | public Cuboid build(double[] val1) { 28 | 29 | return new Cuboid(val1[0], val1[1], val1[2], val1[3], val1[4], val1[5]); 30 | } 31 | 32 | @Override 33 | public void setCoordinates(Cuboid t, double[] val1) { 34 | val1[0] = t.centerx; 35 | val1[1] = t.centery; 36 | val1[2] = t.length; 37 | val1[3] = t.width; 38 | val1[4] = t.height; 39 | val1[5] = t.orientation; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/builder/ParallelCuboidBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.builder; 2 | 3 | import org.locationtech.jts.algorithm.Angle; 4 | import org.locationtech.jts.geom.Coordinate; 5 | import org.locationtech.jts.geom.GeometryFactory; 6 | import org.locationtech.jts.geom.LineString; 7 | import org.locationtech.jts.geom.MultiLineString; 8 | import org.locationtech.jts.operation.distance.DistanceOp; 9 | 10 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 11 | import fr.ign.cogit.geoxygene.util.conversion.AdapterFactory; 12 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 13 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.AbstractParallelCuboid; 14 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.ParallelCuboid; 15 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.ParallelCuboid2; 16 | import fr.ign.mpp.kernel.ObjectBuilder; 17 | 18 | 19 | /** 20 | * This software is released under the licence CeCILL 21 | * 22 | * see LICENSE.TXT 23 | * 24 | * seehttp://www.cecill.info/ 25 | * 26 | * Basic class for ParallelCuboid Sampler. Cuboid are parallel to limits linear geometries 27 | * 28 | * @author MBrasebin 29 | * 30 | */ 31 | public class ParallelCuboidBuilder implements ObjectBuilder{ 32 | 33 | 34 | GeometryFactory factory; 35 | MultiLineString limits; 36 | int bandType; 37 | 38 | 39 | 40 | 41 | public ParallelCuboidBuilder(IGeometry[] limits, int bandType) throws Exception { 42 | factory = new GeometryFactory(); 43 | LineString[] lineStrings = new LineString[limits.length]; 44 | for (int i = 0; i < limits.length; i++) { 45 | lineStrings[i] = (LineString) AdapterFactory.toGeometry(factory, limits[i]); 46 | } 47 | this.limits = factory.createMultiLineString(lineStrings); 48 | this.bandType = bandType; 49 | } 50 | 51 | @Override 52 | public Cuboid build(double[] coordinates) { 53 | Coordinate p = new Coordinate(coordinates[0], coordinates[1]); 54 | DistanceOp op = new DistanceOp(this.limits, factory.createPoint(p)); 55 | Coordinate projected = op.nearestPoints()[0]; 56 | double distance = op.distance(); 57 | double orientation = Angle.angle(p, projected); 58 | AbstractParallelCuboid result; 59 | if (bandType == 1) { 60 | 61 | result = new ParallelCuboid(coordinates[0], coordinates[1], coordinates[2], distance * 2, 62 | coordinates[3], orientation + Math.PI / 2); 63 | 64 | } else { 65 | result = new ParallelCuboid2(coordinates[0], coordinates[1], coordinates[2], distance * 2, 66 | coordinates[3], orientation + Math.PI / 2); 67 | } 68 | return result; 69 | } 70 | 71 | @Override 72 | public int size() { 73 | return 4; 74 | } 75 | 76 | @Override 77 | public void setCoordinates(Cuboid t, double[] coordinates) { 78 | AbstractParallelCuboid pc = (AbstractParallelCuboid) t; 79 | coordinates[0] = pc.centerx; 80 | coordinates[1] = pc.centery; 81 | coordinates[2] = pc.length; 82 | coordinates[3] = pc.height; 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/builder/SimpleCuboidBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.builder; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 4 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.SimpleCuboid; 5 | import fr.ign.mpp.kernel.ObjectBuilder; 6 | 7 | /** 8 | * This software is released under the licence CeCILL 9 | * 10 | * see LICENSE.TXT 11 | * 12 | * see http://www.cecill.info/ 13 | * 14 | * 15 | * Basic class for SimpleCuboid Sampler 16 | * 17 | * @author MBrasebin 18 | * 19 | */ 20 | public class SimpleCuboidBuilder implements ObjectBuilder { 21 | @Override 22 | public int size() { 23 | return 6; 24 | } 25 | 26 | @Override 27 | public Cuboid build(double[] val1) { 28 | 29 | return new SimpleCuboid(val1[0], val1[1], val1[2], val1[3], val1[4], val1[5]); 30 | } 31 | 32 | @Override 33 | public void setCoordinates(Cuboid t, double[] val1) { 34 | val1[0] = t.centerx; 35 | val1[1] = t.centery; 36 | val1[2] = t.length; 37 | val1[3] = t.width; 38 | val1[4] = t.height; 39 | val1[5] = t.orientation; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/builder/SimpleCuboidBuilder2.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.builder; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 4 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.SimpleCuboid2; 5 | import fr.ign.mpp.kernel.ObjectBuilder; 6 | 7 | /** 8 | * This software is released under the licence CeCILL 9 | * 10 | * see LICENSE.TXT 11 | * 12 | * see http://www.cecill.info/ 13 | * 14 | * 15 | * Basic class for SimpleCuboid Sampler 16 | * 17 | * @author MBrasebin 18 | * 19 | */ 20 | public class SimpleCuboidBuilder2 implements ObjectBuilder { 21 | @Override 22 | public int size() { 23 | return 6; 24 | } 25 | 26 | @Override 27 | public Cuboid build(double[] val1) { 28 | 29 | return new SimpleCuboid2(val1[0], val1[1], val1[2], val1[3], val1[4], val1[5]); 30 | } 31 | 32 | @Override 33 | public void setCoordinates(Cuboid t, double[] val1) { 34 | val1[0] = t.centerx; 35 | val1[1] = t.centery; 36 | val1[2] = t.length; 37 | val1[3] = t.width; 38 | val1[4] = t.height; 39 | val1[5] = t.orientation; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/builder/mix/CuboidAbstractSimpleBuildingBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.builder.mix; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.AbstractSimpleBuilding; 4 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 5 | import fr.ign.mpp.kernel.ObjectBuilder; 6 | 7 | 8 | /** 9 | * This software is released under the licence CeCILL 10 | * 11 | * see LICENSE.TXT 12 | * 13 | * see http://www.cecill.info/ 14 | * 15 | * 16 | * Basic class for Cuboid Sampler 17 | * 18 | * @author MBrasebin 19 | * 20 | */ 21 | public class CuboidAbstractSimpleBuildingBuilder implements ObjectBuilder{ 22 | @Override 23 | public int size() { 24 | return 6; 25 | } 26 | 27 | @Override 28 | public Cuboid build(double[] val1) { 29 | 30 | return new Cuboid(val1[0], val1[1], val1[2], val1[3], val1[4], val1[5]); 31 | } 32 | 33 | @Override 34 | public void setCoordinates(AbstractSimpleBuilding t, double[] val1) { 35 | val1[0] = t.centerx; 36 | val1[1] = t.centery; 37 | val1[2] = t.length; 38 | val1[3] = t.width; 39 | val1[4] = t.height; 40 | val1[5] = t.orientation; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/builder/mix/ParallelCuboidAbstractSimpleBuildingBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.builder.mix; 2 | 3 | import org.locationtech.jts.algorithm.Angle; 4 | import org.locationtech.jts.geom.Coordinate; 5 | import org.locationtech.jts.geom.GeometryFactory; 6 | import org.locationtech.jts.geom.LineString; 7 | import org.locationtech.jts.geom.MultiLineString; 8 | import org.locationtech.jts.operation.distance.DistanceOp; 9 | 10 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 11 | import fr.ign.cogit.geoxygene.util.conversion.AdapterFactory; 12 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.AbstractSimpleBuilding; 13 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.AbstractParallelCuboid; 14 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.ParallelCuboid; 15 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.ParallelCuboid2; 16 | import fr.ign.mpp.kernel.ObjectBuilder; 17 | 18 | 19 | /** 20 | * This software is released under the licence CeCILL 21 | * 22 | * see LICENSE.TXT 23 | * 24 | * see http://www.cecill.info/ 25 | * 26 | * Basic class for ParallelCuboid Sampler. Cuboid are parallel to limits linear geometries 27 | * 28 | * @author MBrasebin 29 | * 30 | */ 31 | public class ParallelCuboidAbstractSimpleBuildingBuilder implements ObjectBuilder{ 32 | 33 | 34 | GeometryFactory factory; 35 | MultiLineString limits; 36 | int bandType; 37 | 38 | public ParallelCuboidAbstractSimpleBuildingBuilder(IGeometry[] limits, int bandType) throws Exception { 39 | factory = new GeometryFactory(); 40 | LineString[] lineStrings = new LineString[limits.length]; 41 | for (int i = 0; i < limits.length; i++) { 42 | lineStrings[i] = (LineString) AdapterFactory.toGeometry(factory, limits[i]); 43 | } 44 | this.limits = factory.createMultiLineString(lineStrings); 45 | this.bandType = bandType; 46 | } 47 | 48 | @Override 49 | public AbstractSimpleBuilding build(double[] coordinates) { 50 | Coordinate p = new Coordinate(coordinates[0], coordinates[1]); 51 | DistanceOp op = new DistanceOp(this.limits, factory.createPoint(p)); 52 | Coordinate projected = op.nearestPoints()[0]; 53 | double distance = op.distance(); 54 | double orientation = Angle.angle(p, projected); 55 | AbstractParallelCuboid result; 56 | if (bandType == 1) { 57 | 58 | result = new ParallelCuboid(coordinates[0], coordinates[1], coordinates[2], distance * 2, 59 | coordinates[3], orientation + Math.PI / 2); 60 | 61 | } else { 62 | result = new ParallelCuboid2(coordinates[0], coordinates[1], coordinates[2], distance * 2, 63 | coordinates[3], orientation + Math.PI / 2); 64 | 65 | } 66 | 67 | return result; 68 | } 69 | 70 | @Override 71 | public int size() { 72 | return 4; 73 | } 74 | 75 | @Override 76 | public void setCoordinates(AbstractSimpleBuilding t, double[] coordinates) { 77 | AbstractParallelCuboid pc = (AbstractParallelCuboid) t; 78 | coordinates[0] = pc.centerx; 79 | coordinates[1] = pc.centery; 80 | coordinates[2] = pc.length; 81 | coordinates[3] = pc.height; 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/builder/mix/SimpleCuboidAbstractSimpleBuildingBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.builder.mix; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.AbstractSimpleBuilding; 4 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 5 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.SimpleCuboid; 6 | import fr.ign.mpp.kernel.ObjectBuilder; 7 | 8 | /** 9 | * This software is released under the licence CeCILL 10 | * 11 | * see LICENSE.TXT 12 | * 13 | * see http://www.cecill.info/ 14 | * 15 | * 16 | * Basic class for SimpleCuboid Sampler 17 | * 18 | * @author MBrasebin 19 | * 20 | */ 21 | public class SimpleCuboidAbstractSimpleBuildingBuilder implements ObjectBuilder { 22 | @Override 23 | public int size() { 24 | return 6; 25 | } 26 | 27 | @Override 28 | public Cuboid build(double[] val1) { 29 | 30 | return new SimpleCuboid(val1[0], val1[1], val1[2], val1[3], val1[4], val1[5]); 31 | } 32 | 33 | @Override 34 | public void setCoordinates(AbstractSimpleBuilding t, double[] val1) { 35 | val1[0] = t.centerx; 36 | val1[1] = t.centery; 37 | val1[2] = t.length; 38 | val1[3] = t.width; 39 | val1[4] = t.height; 40 | val1[5] = t.orientation; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/builder/mix/SimpleCuboidAbstractSimpleBuildingBuilder2.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.builder.mix; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.AbstractSimpleBuilding; 4 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple.SimpleCuboid2; 5 | import fr.ign.mpp.kernel.ObjectBuilder; 6 | 7 | /** 8 | * This software is released under the licence CeCILL 9 | * 10 | * see LICENSE.TXT 11 | * 12 | * see http://www.cecill.info/ 13 | * 14 | * 15 | * Basic class for SimpleCuboid Sampler 16 | * 17 | * @author MBrasebin 18 | * 19 | */ 20 | public class SimpleCuboidAbstractSimpleBuildingBuilder2 implements ObjectBuilder { 21 | @Override 22 | public int size() { 23 | return 6; 24 | } 25 | 26 | @Override 27 | public AbstractSimpleBuilding build(double[] val1) { 28 | 29 | return new SimpleCuboid2(val1[0], val1[1], val1[2], val1[3], val1[4], val1[5]); 30 | } 31 | 32 | @Override 33 | public void setCoordinates(AbstractSimpleBuilding t, double[] val1) { 34 | val1[0] = t.centerx; 35 | val1[1] = t.centery; 36 | val1[2] = t.length; 37 | val1[3] = t.width; 38 | val1[4] = t.height; 39 | val1[5] = t.orientation; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/impl/AbstractSimpleBuilding.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl; 2 | 3 | import org.locationtech.jts.geom.Geometry; 4 | import org.locationtech.jts.geom.Polygon; 5 | 6 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 7 | import fr.ign.cogit.simplu3d.model.Building; 8 | import fr.ign.cogit.simplu3d.rjmcmc.generic.object.ISimPLU3DPrimitive; 9 | 10 | /** 11 | * 12 | * This software is released under the licence CeCILL 13 | * 14 | * see LICENSE.TXT 15 | * 16 | * see http://www.cecill.info/ 17 | * 18 | * 19 | * 20 | * copyright IGN 21 | * 22 | * @author Brasebin Mickaël 23 | * 24 | * @version 1.0 25 | **/ 26 | public abstract class AbstractSimpleBuilding extends Building implements ISimPLU3DPrimitive { 27 | 28 | public double centerx; 29 | public double centery; 30 | public double length; 31 | public double width; 32 | public double orientation = 0; 33 | public double height; 34 | 35 | public AbstractSimpleBuilding() { 36 | super(); 37 | } 38 | 39 | public abstract Polygon toGeometry(); 40 | 41 | public abstract boolean prospectJTS(Geometry geom, double slope, double hIni); 42 | 43 | public abstract IGeometry generated3DGeom(); 44 | 45 | public abstract void setCoordinates(double[] val1); 46 | 47 | @Override 48 | public boolean equals(Object obj) { 49 | 50 | if (this == obj) { 51 | return true; 52 | } 53 | 54 | if (this.getClass() != obj.getClass()) { 55 | return false; 56 | } 57 | 58 | double[] array1 = this.toArray(); 59 | double[] array2 = this.toArray(); 60 | 61 | return array1.equals(array2); 62 | } 63 | 64 | public double getCenterx() { 65 | return centerx; 66 | } 67 | 68 | public double getCentery() { 69 | return centery; 70 | } 71 | 72 | public double getLength() { 73 | return length; 74 | } 75 | 76 | public double getWidth() { 77 | return width; 78 | } 79 | 80 | public double getOrientation() { 81 | return orientation; 82 | } 83 | 84 | public double getHeight() { 85 | return height; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/impl/FastBuildingPart.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * see (z - zMin); 70 | 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * see http://www.cecill.info/ 8 | * 9 | * 10 | * 11 | * copyright IGN 12 | * 13 | * @author Brasebin Mickaël 14 | * 15 | * @version 1.0 16 | **/ 17 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl; -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/loader/LoaderCuboid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.loader; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import fr.ign.cogit.geoxygene.api.feature.IFeature; 7 | import fr.ign.cogit.geoxygene.api.feature.IFeatureCollection; 8 | import fr.ign.cogit.geoxygene.api.spatial.coordgeom.IDirectPositionList; 9 | import fr.ign.cogit.geoxygene.api.spatial.coordgeom.IPolygon; 10 | import fr.ign.cogit.geoxygene.api.spatial.geomaggr.IMultiSurface; 11 | import fr.ign.cogit.geoxygene.api.spatial.geomprim.IOrientableSurface; 12 | import fr.ign.cogit.geoxygene.contrib.geometrie.Angle; 13 | import fr.ign.cogit.geoxygene.contrib.geometrie.Vecteur; 14 | import fr.ign.cogit.geoxygene.convert.FromGeomToSurface; 15 | import fr.ign.cogit.geoxygene.sig3d.calculation.OrientedBoundingBox; 16 | import fr.ign.cogit.geoxygene.sig3d.equation.ApproximatedPlanEquation; 17 | import fr.ign.cogit.geoxygene.util.conversion.ShapefileReader; 18 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 19 | /** 20 | * 21 | * This software is released under the licence CeCILL 22 | * 23 | * see LICENSE.TXT 24 | * 25 | * see http://www.cecill.info/ 26 | * 27 | * 28 | * 29 | * copyright IGN 30 | * 31 | * @author Brasebin Mickaël 32 | * 33 | * @version 1.0 34 | **/ 35 | public class LoaderCuboid { 36 | 37 | public static List loadFromShapeFile(String shapeFile) { 38 | return loadFromCollection(ShapefileReader.read(shapeFile)); 39 | } 40 | 41 | public static List loadFromCollection(IFeatureCollection featColl) { 42 | List lCub = new ArrayList<>(); 43 | for (IFeature feat : featColl) { 44 | lCub.add(transformFeature(feat)); 45 | } 46 | return lCub; 47 | } 48 | 49 | public static Cuboid transformFeature(IFeature feat) { 50 | IMultiSurface iMS = FromGeomToSurface.convertMSGeom(feat.getGeom()); 51 | OrientedBoundingBox oBB = new OrientedBoundingBox(iMS); 52 | IPolygon poly = oBB.getPoly(); 53 | ApproximatedPlanEquation ap = new ApproximatedPlanEquation(poly); 54 | if (ap.getNormale().getZ() < 0) { 55 | poly = (IPolygon) poly.reverse(); 56 | } 57 | IDirectPositionList dpl = poly.coord(); 58 | double l = dpl.get(0).distance(dpl.get(1)); 59 | double w = dpl.get(2).distance(dpl.get(1)); 60 | double centreX = oBB.getCentre().getX(); 61 | double centreY = oBB.getCentre().getY(); 62 | Vecteur v = new Vecteur( 63 | (dpl.get(1).getX() + dpl.get(2).getX()) / 2 - centreX, 64 | (dpl.get(1).getY() + dpl.get(2).getY()) / 2 - centreY); 65 | Angle a = v.direction(); 66 | return new Cuboid(centreX, centreY, l, w, oBB.getzMax() - oBB.getzMin(), a.getValeur()); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/loader/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * see http://www.cecill.info/ 8 | * 9 | * 10 | * 11 | * copyright IGN 12 | * 13 | * @author Brasebin Mickaël 14 | * 15 | * @version 1.0 16 | **/ 17 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.loader; -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * see http://www.cecill.info/ 8 | * 9 | * 10 | * 11 | * copyright IGN 12 | * 13 | * @author Brasebin Mickaël 14 | * 15 | * @version 1.0 16 | **/ 17 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry; -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/simple/AbstractParallelCuboid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple; 2 | 3 | import java.util.List; 4 | 5 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 6 | 7 | public abstract class AbstractParallelCuboid extends Cuboid { 8 | 9 | public AbstractParallelCuboid(double centerx, double centery, double length, double width, double height, double orientation) { 10 | super(centerx, centery, length, width, height, orientation); 11 | } 12 | @Override 13 | public Object[] getArray() { 14 | return new Object[] { this.centerx, this.centery, this.length/*, this.width*/, this.height/*, this.orientation*/ }; 15 | } 16 | 17 | @Override 18 | public int size() { 19 | return 4; 20 | } 21 | 22 | @Override 23 | public int hashCode() { 24 | int hashCode = 1; 25 | double[] array = { this.centerx, this.centery, this.length/*, this.width*/, this.orientation/*, this.height*/ }; 26 | for (double e : array) 27 | hashCode = 31 * hashCode + hashCode(e); 28 | return hashCode; 29 | } 30 | 31 | @Override 32 | public boolean equals(Object o) { 33 | if (!(o instanceof ParallelCuboid)) { 34 | return false; 35 | } 36 | ParallelCuboid r = (ParallelCuboid) o; 37 | return (this.centerx== r.centerx) && (this.centery== r.centery) 38 | && (this.width== r.width) && (this.length== r.length) 39 | && (this.orientation== r.orientation) && (this.height== r.height); 40 | } 41 | 42 | public String toString() { 43 | return "ParallelCuboid : " + " Centre " + this.centerx + "; " + this.centery + " hauteur " + this.height + " largeur " 44 | + this.width + " longueur " + this.width + " orientation " + this.orientation; 45 | 46 | } 47 | @Override 48 | public double[] toArray() { 49 | return new double[] { this.centerx, this.centery, this.length/*, this.width*/, this.height/*, this.orientation*/ }; 50 | } 51 | 52 | @Override 53 | public void set(List list) { 54 | this.centerx = list.get(0); 55 | this.centery = list.get(1); 56 | this.length = list.get(2); 57 | // this.width = list.get(3); 58 | this.height = list.get(3); 59 | // this.orientation = list.get(5); 60 | this.setNew(true); 61 | } 62 | 63 | 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/simple/ParallelCuboid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple; 2 | 3 | /** 4 | * 5 | * This software is released under the licence CeCILL 6 | * 7 | * see LICENSE.TXT 8 | * 9 | * see http://www.cecill.info/ 10 | * 11 | * 12 | * 13 | * copyright IGN 14 | * 15 | * @author mbrasebin 16 | **/ 17 | public class ParallelCuboid extends AbstractParallelCuboid { 18 | 19 | public ParallelCuboid(double centerx, double centery, double length, 20 | double width, double height, double orientation) { 21 | super(centerx, centery, length, width, height, orientation); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/simple/ParallelCuboid2.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple; 2 | 3 | public class ParallelCuboid2 extends AbstractParallelCuboid { 4 | 5 | public ParallelCuboid2(double centerx, double centery, double length, 6 | double width, double height, double orientation) { 7 | super(centerx, centery, length, width, height, orientation); 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/simple/SimpleCuboid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 4 | 5 | /** 6 | * 7 | * This software is released under the licence CeCILL 8 | * 9 | * see LICENSE.TXT 10 | * 11 | * see http://www.cecill.info/ 12 | * 13 | * 14 | * 15 | * copyright IGN 16 | * @author mbrasebin 17 | **/ 18 | public class SimpleCuboid extends Cuboid { 19 | public SimpleCuboid(double centerx, double centery, double length, double width, double height, double orientation) { 20 | super(centerx, centery, length, width, height, orientation); 21 | } 22 | 23 | @Override 24 | public boolean equals(Object o) { 25 | if (!(o instanceof SimpleCuboid)) { 26 | return false; 27 | } 28 | SimpleCuboid r = (SimpleCuboid) o; 29 | return (this.centerx== r.centerx) && (this.centery== r.centery) 30 | && (this.width== r.width) && (this.length== r.length) 31 | && (this.orientation== r.orientation) && (this.height== r.height); 32 | } 33 | 34 | public String toString() { 35 | return "SimpleCuboid : " + " Centre " + this.centerx + "; " + this.centery + " hauteur " + this.height 36 | + " largeur " + this.width + " longueur " + this.width + " orientation " + this.orientation; 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/geometry/simple/SimpleCuboid2.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.simple; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 4 | 5 | /** 6 | * 7 | * This software is released under the licence CeCILL 8 | * 9 | * see LICENSE.TXT 10 | * 11 | * see http://www.cecill.info/ 12 | * 13 | * @author MBrasebin 14 | * 15 | * copyright IGN 16 | * 17 | **/ 18 | public class SimpleCuboid2 extends Cuboid { 19 | public SimpleCuboid2(double centerx, double centery, double length, double width, double height, double orientation) { 20 | super(centerx, centery, length, width, height, orientation); 21 | } 22 | 23 | @Override 24 | public boolean equals(Object o) { 25 | if (!(o instanceof SimpleCuboid2)) { 26 | return false; 27 | } 28 | SimpleCuboid2 r = (SimpleCuboid2) o; 29 | return (this.centerx== r.centerx) && (this.centery== r.centery) 30 | && (this.width== r.width) && (this.length== r.length) 31 | && (this.orientation== r.orientation) && (this.height== r.height); 32 | } 33 | 34 | public String toString() { 35 | return "SimpleCuboid : " + " Centre " + this.centerx + "; " + this.centery + " hauteur " + this.height 36 | + " largeur " + this.width + " longueur " + this.width + " orientation " + this.orientation; 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/optimizer/cuboid/OptimisedBuildingsCuboidDirectRejectionNoVisitor.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.optimizer.cuboid; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.commons.math3.random.RandomGenerator; 7 | import org.locationtech.jts.geom.GeometryFactory; 8 | 9 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 10 | import fr.ign.cogit.geoxygene.util.conversion.AdapterFactory; 11 | import fr.ign.cogit.simplu3d.model.BasicPropertyUnit; 12 | import fr.ign.cogit.simplu3d.model.Environnement; 13 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 14 | import fr.ign.cogit.simplu3d.util.SimpluParameters; 15 | import fr.ign.mpp.configuration.BirthDeathModification; 16 | import fr.ign.mpp.configuration.GraphConfiguration; 17 | import fr.ign.rjmcmc.configuration.ConfigurationModificationPredicate; 18 | import fr.ign.rjmcmc.sampler.Sampler; 19 | import fr.ign.simulatedannealing.SimulatedAnnealing; 20 | import fr.ign.simulatedannealing.endtest.EndTest; 21 | import fr.ign.simulatedannealing.schedule.Schedule; 22 | import fr.ign.simulatedannealing.temperature.SimpleTemperature; 23 | import fr.ign.simulatedannealing.visitor.CompositeVisitor; 24 | import fr.ign.simulatedannealing.visitor.Visitor; 25 | 26 | /** 27 | * 28 | * This software is released under the licence CeCILL 29 | * 30 | * see LICENSE.TXT 31 | * 32 | * see http://www.cecill.info/ 33 | * 34 | * 35 | * 36 | * copyright IGN 37 | * 38 | * @author Brasebin Mickaël 39 | * 40 | * @version 1.0 41 | * 42 | * Classe d'optimisation sans visiteur pour calcul distribués 43 | * 44 | * 45 | */ 46 | public class OptimisedBuildingsCuboidDirectRejectionNoVisitor extends BasicCuboidOptimizer { 47 | 48 | public GraphConfiguration process(RandomGenerator rng, BasicPropertyUnit bpu, SimpluParameters p, 49 | Environnement env, 50 | ConfigurationModificationPredicate, BirthDeathModification> pred) { 51 | // Géométrie de l'unité foncière sur laquelle porte la génération 52 | IGeometry geom = bpu.generateGeom().buffer(1); 53 | 54 | // Définition de la fonction d'optimisation (on optimise en décroissant) 55 | // relative au volume 56 | GraphConfiguration conf = null; 57 | try { 58 | conf = create_configuration(p, AdapterFactory.toGeometry(new GeometryFactory(), geom), bpu); 59 | } catch (Exception e) { 60 | e.printStackTrace(); 61 | } 62 | // Création de l'échantilloneur 63 | Sampler, BirthDeathModification> samp = create_sampler(rng, p, bpu, pred); 64 | // Température 65 | Schedule sch = create_schedule(p); 66 | 67 | EndTest end = create_end_test(p); 68 | 69 | List, BirthDeathModification>> list = new ArrayList<>(); 70 | CompositeVisitor, BirthDeathModification> mVisitor = new CompositeVisitor<>( 71 | list); 72 | 73 | SimulatedAnnealing.optimize(rng, conf, samp, sch, end, mVisitor); 74 | return conf; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/optimizer/cuboid/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * see http://www.cecill.info/ 8 | * 9 | * 10 | * 11 | * copyright IGN 12 | * 13 | * @author Brasebin Mickaël 14 | * 15 | * @version 1.0 16 | **/ 17 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.optimizer.cuboid; -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/optimizer/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * see http://www.cecill.info/ 8 | * 9 | * 10 | * 11 | * copyright IGN 12 | * 13 | * @author Brasebin Mickaël 14 | * 15 | * @version 1.0 16 | **/ 17 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.optimizer; -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * see http://www.cecill.info/ 8 | * 9 | * 10 | * 11 | * copyright IGN 12 | * 13 | * @author Brasebin Mickaël 14 | * 15 | * @version 1.0 16 | **/ 17 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid; -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/sampler/MixAbstractBuildingSampler.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.sampler; 2 | 3 | import org.apache.commons.math3.random.RandomGenerator; 4 | 5 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.AbstractSimpleBuilding; 6 | import fr.ign.mpp.kernel.ObjectBuilder; 7 | import fr.ign.mpp.kernel.ObjectSampler; 8 | import fr.ign.rjmcmc.kernel.Transform; 9 | import fr.ign.rjmcmc.kernel.Variate; 10 | 11 | public class MixAbstractBuildingSampler implements ObjectSampler { 12 | 13 | RandomGenerator engine; 14 | double p_simple; 15 | AbstractSimpleBuilding object; 16 | Variate variate; 17 | Transform transformBand2; 18 | Transform transformBand1; 19 | ObjectBuilder builder1; 20 | ObjectBuilder builder2; 21 | Class c1; 22 | Class c2; 23 | 24 | public MixAbstractBuildingSampler(RandomGenerator e, double p_simple, Transform transformBand1, Transform transformBand2, 25 | ObjectBuilder builder1, ObjectBuilder builder2, 26 | Class c1, Class c2) { 27 | this.engine = e; 28 | this.p_simple = p_simple; 29 | this.transformBand2 = transformBand2; 30 | this.transformBand1 = transformBand1; 31 | this.variate = new Variate(e); 32 | this.builder1 = builder1; 33 | this.builder2 = builder2; 34 | this.c1 = c1; 35 | this.c2 = c2; 36 | } 37 | 38 | @Override 39 | public double sample(RandomGenerator e) { 40 | double[] val0; 41 | double[] val1; 42 | if (engine.nextDouble() < p_simple) { 43 | val0 = new double[builder2.size()]; 44 | val1 = new double[builder2.size()]; 45 | double phi = this.variate.compute(val0, 0); 46 | double jacob = this.transformBand2.apply(true, val0, val1); 47 | this.object = builder2.build(val1); 48 | return phi / jacob; 49 | } 50 | val0 = new double[builder1.size()]; 51 | val1 = new double[builder1.size()]; 52 | double phi = this.variate.compute(val0, 0); 53 | double jacob = this.transformBand1.apply(true, val0, val1); 54 | this.object = builder1.build(val1); 55 | return phi / jacob; 56 | } 57 | 58 | @Override 59 | public double pdf(AbstractSimpleBuilding t) { 60 | if (c2 != null && c2.isInstance(t)) { 61 | double[] val1 = new double[builder2.size()]; 62 | builder2.setCoordinates(t, val1); 63 | double[] val0 = new double[builder2.size()]; 64 | double J10 = this.transformBand2.apply(false, val1, val0); 65 | double pdf = this.variate.pdf(val0, 0); 66 | return pdf * J10; 67 | } 68 | 69 | double[] val1 = new double[builder1.size()]; 70 | builder1.setCoordinates(t, val1); 71 | double[] val0 = new double[builder1.size()]; 72 | double J10 = this.transformBand1.apply(false, val1, val0); 73 | if (J10 == 0) { 74 | return 0; 75 | } 76 | double pdf = this.variate.pdf(val0, 0); 77 | return pdf * J10; 78 | } 79 | 80 | @Override 81 | public AbstractSimpleBuilding getObject() { 82 | return this.object; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/sampler/MixCuboidSampler.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.sampler; 2 | 3 | import org.apache.commons.math3.random.RandomGenerator; 4 | 5 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 6 | import fr.ign.mpp.kernel.ObjectBuilder; 7 | import fr.ign.mpp.kernel.ObjectSampler; 8 | import fr.ign.rjmcmc.kernel.Transform; 9 | import fr.ign.rjmcmc.kernel.Variate; 10 | 11 | public class MixCuboidSampler implements ObjectSampler { 12 | 13 | RandomGenerator engine; 14 | double p_simple; 15 | Cuboid object; 16 | Variate variate; 17 | Transform transformBand2; 18 | Transform transformBand1; 19 | ObjectBuilder builder1; 20 | ObjectBuilder builder2; 21 | Class c1; 22 | Class c2; 23 | 24 | public MixCuboidSampler(RandomGenerator e, double p_simple, Transform transformBand1, Transform transformBand2, 25 | ObjectBuilder builder1, ObjectBuilder builder2, Class c1, Class c2) { 26 | this.engine = e; 27 | this.p_simple = p_simple; 28 | this.transformBand2 = transformBand2; 29 | this.transformBand1 = transformBand1; 30 | this.variate = new Variate(e); 31 | this.builder1 = builder1; 32 | this.builder2 = builder2; 33 | this.c1 = c1; 34 | this.c2 = c2; 35 | } 36 | 37 | @Override 38 | public double sample(RandomGenerator e) { 39 | double[] val0; 40 | double[] val1; 41 | if (engine.nextDouble() < p_simple) { 42 | val0 = new double[builder2.size()]; 43 | val1 = new double[builder2.size()]; 44 | double phi = this.variate.compute(val0, 0); 45 | double jacob = this.transformBand2.apply(true, val0, val1); 46 | this.object = builder2.build(val1); 47 | return phi / jacob; 48 | } 49 | val0 = new double[builder1.size()]; 50 | val1 = new double[builder1.size()]; 51 | double phi = this.variate.compute(val0, 0); 52 | double jacob = this.transformBand1.apply(true, val0, val1); 53 | this.object = builder1.build(val1); 54 | return phi / jacob; 55 | } 56 | 57 | @Override 58 | public double pdf(Cuboid t) { 59 | if (c2 != null && c2.isInstance(t)) { 60 | double[] val1 = new double[builder2.size()]; 61 | builder2.setCoordinates(t, val1); 62 | double[] val0 = new double[builder2.size()]; 63 | double J10 = this.transformBand2.apply(false, val1, val0); 64 | double pdf = this.variate.pdf(val0, 0); 65 | return pdf * J10; 66 | } 67 | 68 | double[] val1 = new double[builder1.size()]; 69 | builder1.setCoordinates(t, val1); 70 | double[] val0 = new double[builder1.size()]; 71 | double J10 = this.transformBand1.apply(false, val1, val0); 72 | if (J10 == 0) { 73 | return 0; 74 | } 75 | double pdf = this.variate.pdf(val0, 0); 76 | return pdf * J10; 77 | } 78 | 79 | @Override 80 | public Cuboid getObject() { 81 | return this.object; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/ChangeHeight.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | 5 | /** 6 | * 7 | * This software is released under the licence CeCILL 8 | * 9 | * see LICENSE.TXT 10 | * 11 | * see http://www.cecill.info/ 12 | * 13 | * 14 | * 15 | * copyright IGN 16 | * 17 | * @author Brasebin Mickaël 18 | * 19 | * @version 1.0 20 | **/ 21 | public class ChangeHeight implements Transform { 22 | 23 | private double amplitude; 24 | 25 | public ChangeHeight(double amplitude) { 26 | this.amplitude = amplitude; 27 | } 28 | 29 | @Override 30 | public double apply(boolean direct, double[] val0, double[] val1) { 31 | 32 | double dh = val0[6]; 33 | 34 | val1[0] = val0[0]; 35 | val1[1] = val0[1]; 36 | val1[2] = val0[2]; 37 | val1[3] = val0[3]; 38 | val1[4] = val0[4] + (0.5 - dh) * amplitude; 39 | val1[5] = val0[5]; 40 | 41 | val1[6] = 1 - dh; 42 | 43 | return 1; 44 | } 45 | 46 | // @Override 47 | public double getAbsJacobian(boolean direct) { 48 | return 1; 49 | } 50 | 51 | @Override 52 | public int dimension() { 53 | return 7; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/ChangeLength.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | 5 | /** 6 | * 7 | * This software is released under the licence CeCILL 8 | * 9 | * see LICENSE.TXT 10 | * 11 | * see http://www.cecill.info/ 12 | * 13 | * 14 | * 15 | * copyright IGN 16 | * 17 | * @author Brasebin Mickaël 18 | * 19 | * @version 1.0 20 | **/ 21 | public class ChangeLength implements Transform { 22 | 23 | private double amplitude; 24 | 25 | public ChangeLength(double amplitude) { 26 | this.amplitude = amplitude; 27 | } 28 | 29 | @Override 30 | public double apply(boolean direct, double[] val0, double[] val1) { 31 | 32 | double dl = val0[6]; 33 | 34 | val1[0] = val0[0]; 35 | val1[1] = val0[1]; 36 | val1[2] = val0[2] + (0.5 - dl) * amplitude; 37 | val1[3] = val0[3]; 38 | val1[4] = val0[4]; 39 | val1[5] = val0[5]; 40 | 41 | val1[6] = 1 - dl; 42 | 43 | return 1; 44 | } 45 | 46 | // @Override 47 | public double getAbsJacobian(boolean direct) { 48 | return 1; 49 | } 50 | 51 | @Override 52 | public int dimension() { 53 | return 7; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/ChangeWidth.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | /** 5 | * 6 | * This software is released under the licence CeCILL 7 | * 8 | * see LICENSE.TXT 9 | * 10 | * see http://www.cecill.info/ 11 | * 12 | * 13 | * 14 | * copyright IGN 15 | * 16 | * @author Brasebin Mickaël 17 | * 18 | * @version 1.0 19 | **/ 20 | public class ChangeWidth implements Transform { 21 | 22 | private double amplitude; 23 | 24 | public ChangeWidth(double amplitude) { 25 | this.amplitude = amplitude; 26 | } 27 | 28 | 29 | @Override 30 | public double apply(boolean direct, double[] val0, double[] val1) { 31 | 32 | double dl = val0[6]; 33 | 34 | val1[0] = val0[0]; 35 | val1[1] = val0[1]; 36 | val1[2] = val0[2]; 37 | val1[3] = val0[3] + (0.5 - dl) * amplitude; 38 | val1[4] = val0[4]; 39 | val1[5] = val0[5]; 40 | 41 | val1[6] = 1 - dl; 42 | 43 | return 1; 44 | } 45 | 46 | // @Override 47 | public double getAbsJacobian(boolean direct) { 48 | return 1; 49 | } 50 | 51 | @Override 52 | public int dimension() { 53 | return 7; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/MoveCuboid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | /** 5 | * 6 | * This software is released under the licence CeCILL 7 | * 8 | * see LICENSE.TXT 9 | * 10 | * see http://www.cecill.info/ 11 | * 12 | * 13 | * 14 | * copyright IGN 15 | * 16 | * @author Brasebin Mickaël 17 | * 18 | * @version 1.0 19 | **/ 20 | public class MoveCuboid implements Transform { 21 | 22 | private double amplitudeMove; 23 | 24 | public MoveCuboid(double amplitudeMove) { 25 | this.amplitudeMove = amplitudeMove; 26 | } 27 | 28 | @Override 29 | public double apply(boolean direct, double[] val0, double[] val1) { 30 | 31 | double dx = val0[6]; 32 | double dy = val0[7]; 33 | val1[0] = val0[0] + (0.5 - dx) * amplitudeMove; 34 | val1[1] = val0[1] + (0.5 - dy) * amplitudeMove; 35 | val1[2] = val0[2]; 36 | val1[3] = val0[3]; 37 | val1[4] = val0[4]; 38 | val1[5] = val0[5]; 39 | 40 | val1[6] = 1 - dx; 41 | val1[7] = 1 - dy; 42 | return 1; 43 | } 44 | 45 | // @Override 46 | public double getAbsJacobian(boolean direct) { 47 | return 1; 48 | } 49 | 50 | @Override 51 | public int dimension() { 52 | return 8; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/RotateCuboid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | /** 5 | * 6 | * This software is released under the licence CeCILL 7 | * 8 | * see LICENSE.TXT 9 | * 10 | * see http://www.cecill.info/ 11 | * 12 | * 13 | * 14 | * copyright IGN 15 | * 16 | * @author Brasebin Mickaël 17 | * 18 | * @version 1.0 19 | **/ 20 | public class RotateCuboid implements Transform { 21 | 22 | private double amplitudeRotate; 23 | 24 | public RotateCuboid(double amp) { 25 | amplitudeRotate = amp; 26 | } 27 | 28 | @Override 29 | public double apply(boolean direct, double[] val0, double[] val1) { 30 | 31 | double dor = val0[6]; 32 | double newAngle = val0[5] + (0.5 - dor) * amplitudeRotate; 33 | double modulo = newAngle % (Math.PI); 34 | if (modulo < 0) { 35 | modulo = Math.PI + modulo; 36 | } 37 | val1[0] = val0[0]; 38 | val1[1] = val0[1]; 39 | val1[2] = val0[2]; 40 | val1[3] = val0[3]; 41 | val1[4] = val0[4]; 42 | val1[5] = modulo; 43 | 44 | val1[6] = 1 - dor; 45 | return 1; 46 | } 47 | 48 | // @Override 49 | public double getAbsJacobian(boolean direct) { 50 | return 1; 51 | } 52 | 53 | @Override 54 | public int dimension() { 55 | return 7; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/birth/ParallelCuboidTransform.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation.birth; 2 | 3 | import java.util.Arrays; 4 | import java.util.Iterator; 5 | 6 | import org.apache.logging.log4j.LogManager; 7 | import org.apache.logging.log4j.Logger; 8 | import org.locationtech.jts.geom.Geometry; 9 | import org.locationtech.jts.geom.GeometryFactory; 10 | 11 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 12 | import fr.ign.cogit.geoxygene.util.conversion.AdapterFactory; 13 | import fr.ign.cogit.simplu3d.rjmcmc.generic.transform.SimplePolygonTransform; 14 | import fr.ign.geometry.transform.PolygonTransform; 15 | import fr.ign.rjmcmc.kernel.Transform; 16 | 17 | /** 18 | * 19 | * This software is released under the licence CeCILL 20 | * 21 | * see LICENSE.TXT 22 | * 23 | * see http://www.cecill.info/ 24 | * 25 | * copyright IGN 26 | * 27 | * @version 1.0 28 | **/ 29 | public class ParallelCuboidTransform implements Transform { 30 | /** 31 | * Logger. 32 | */ 33 | static Logger LOGGER = LogManager.getLogger(ParallelCuboidTransform.class.getName()); 34 | 35 | private double absJacobian[]; 36 | private PolygonTransform polygonTransform; 37 | // private MultiLineString limits; 38 | private GeometryFactory factory = new GeometryFactory(); 39 | 40 | private double deltaLength; 41 | private double deltaHeight; 42 | private double rangeLength; 43 | private double rangeHeight; 44 | 45 | private boolean isValid = false; 46 | 47 | /** 48 | * 49 | * @return Indicate if the transform is valid (i.e: that the triangulation in the PolygonTransform is ok) 50 | */ 51 | public boolean isValid(){ 52 | return isValid; 53 | } 54 | 55 | public ParallelCuboidTransform(double[] d, double[] v, IGeometry polygon) 56 | throws Exception { 57 | this.rangeLength = d[2]; 58 | this.rangeHeight = d[3]; 59 | this.deltaLength = v[2]; 60 | this.deltaHeight = v[3]; 61 | double determinant = rangeLength * rangeHeight; 62 | // LineString[] lineStrings = new LineString[limits.length]; 63 | // for (int i = 0; i < limits.length; i++) { 64 | // lineStrings[i] = (LineString) AdapterFactory.toGeometry(factory, limits[i]); 65 | // } 66 | // this.limits = factory.createMultiLineString(lineStrings); 67 | Geometry pp = AdapterFactory.toGeometry(factory, polygon); 68 | Iterator testedSnapping = Arrays.asList(0.1,0.001,0.0).iterator(); 69 | 70 | while(testedSnapping.hasNext() && ! isValid) { 71 | this.polygonTransform = new PolygonTransform(pp, testedSnapping.next()); 72 | isValid = this.polygonTransform.isValid(); 73 | } 74 | 75 | if (!isValid) { 76 | this.polygonTransform = new SimplePolygonTransform(pp); 77 | this.isValid = polygonTransform.isValid(); 78 | 79 | } 80 | 81 | if(isValid) { 82 | this.absJacobian = new double[2]; 83 | this.absJacobian[0] = Math.abs(determinant) * this.polygonTransform.getAbsJacobian(true); 84 | this.absJacobian[1] = Math.abs(1 / determinant) * this.polygonTransform.getAbsJacobian(false); 85 | } 86 | } 87 | 88 | @Override 89 | public double apply(boolean direct, double[] val0, double[] val1) { 90 | double pt = this.polygonTransform.apply(direct, val0, val1); 91 | if (direct) { 92 | // Coordinate p = new Coordinate(val1.get(0), val1.get(1)); 93 | // DistanceOp op = new DistanceOp(this.limits, factory.createPoint(p)); 94 | // Coordinate projected = op.nearestPoints()[0]; 95 | // double distance = op.distance(); 96 | // double orientation = Angle.angle(p, projected); 97 | val1[2] = val0[2] * rangeLength + deltaLength; 98 | // val1.set(3, distance * 2); 99 | val1[3] = val0[3] * rangeHeight + deltaHeight; 100 | // val1.set(5, orientation + Math.PI / 2); 101 | return pt * this.absJacobian[0]; 102 | } else { 103 | val1[2] = (val0[2] - deltaLength) / rangeLength; 104 | val1[3] = (val0[3] - deltaHeight) / rangeHeight; 105 | // var1.set(4, 0.0); 106 | // var1.set(5, 0.0); 107 | return pt * this.absJacobian[1]; 108 | } 109 | } 110 | 111 | // @Override 112 | public double getAbsJacobian(boolean direct) { 113 | return this.absJacobian[direct ? 0 : 1]; 114 | } 115 | 116 | @Override 117 | public int dimension() { 118 | return 4; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/birth/ParallelPolygonTransform.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation.birth; 2 | 3 | import java.util.Arrays; 4 | import java.util.Iterator; 5 | 6 | import org.apache.logging.log4j.LogManager; 7 | import org.apache.logging.log4j.Logger; 8 | import org.locationtech.jts.geom.Geometry; 9 | import org.locationtech.jts.geom.GeometryFactory; 10 | 11 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 12 | import fr.ign.cogit.geoxygene.util.conversion.AdapterFactory; 13 | import fr.ign.cogit.simplu3d.rjmcmc.generic.transform.SimplePolygonTransform; 14 | import fr.ign.geometry.transform.PolygonTransform; 15 | import fr.ign.rjmcmc.kernel.Transform; 16 | 17 | /** 18 | * 19 | * This software is released under the licence CeCILL 20 | * 21 | * see LICENSE.TXT 22 | * 23 | * see http://www.cecill.info/ 24 | * 25 | * copyright IGN 26 | * 27 | * @version 1.0 28 | **/ 29 | public class ParallelPolygonTransform implements Transform { 30 | /** 31 | * Logger. 32 | */ 33 | static Logger LOGGER = LogManager.getLogger(ParallelPolygonTransform.class.getName()); 34 | 35 | private double absJacobian[]; 36 | private PolygonTransform polygonTransform; 37 | // private MultiLineString limits; 38 | private GeometryFactory factory = new GeometryFactory(); 39 | 40 | private double deltaLength; 41 | private double deltaHeight; 42 | private double rangeLength; 43 | private double rangeHeight; 44 | 45 | private boolean isValid = false; 46 | 47 | public ParallelPolygonTransform(double[] d, double[] v, IGeometry polygon) throws Exception { 48 | this.rangeLength = d[2]; 49 | this.rangeHeight = d[4]; 50 | this.deltaLength = v[2]; 51 | this.deltaHeight = v[4]; 52 | double determinant = rangeLength * rangeHeight; 53 | // LineString[] lineStrings = new LineString[limits.length]; 54 | // for (int i = 0; i < limits.length; i++) { 55 | // lineStrings[i] = (LineString) AdapterFactory.toGeometry(factory, limits[i]); 56 | // } 57 | // this.limits = factory.createMultiLineString(lineStrings); 58 | Geometry pp = AdapterFactory.toGeometry(factory, polygon); 59 | 60 | Iterator testedSnapping = Arrays.asList(0.1, 0.001, 0.0).iterator(); 61 | 62 | while (testedSnapping.hasNext() && !isValid) { 63 | 64 | try { 65 | this.polygonTransform = new PolygonTransform(pp, testedSnapping.next()); 66 | isValid = this.polygonTransform.isValid(); 67 | } catch (Exception e) { 68 | e.printStackTrace(); 69 | } 70 | 71 | } 72 | 73 | if (!isValid) { 74 | this.polygonTransform = new SimplePolygonTransform(pp); 75 | this.isValid = polygonTransform.isValid(); 76 | 77 | } 78 | 79 | if (isValid) { 80 | this.absJacobian = new double[2]; 81 | this.absJacobian[0] = Math.abs(determinant) * this.polygonTransform.getAbsJacobian(true); 82 | this.absJacobian[1] = Math.abs(1 / determinant) * this.polygonTransform.getAbsJacobian(false); 83 | } 84 | 85 | } 86 | 87 | /** 88 | * Indicate if the transform is valid (i.e: that the triangulation in the 89 | * PolygonTransform is ok) 90 | * 91 | * @return indicate if the transform is valid 92 | */ 93 | public boolean isValid() { 94 | return isValid; 95 | } 96 | 97 | @Override 98 | public double apply(boolean direct, double[] val0, double[] val1) { 99 | double pt = this.polygonTransform.apply(direct, val0, val1); 100 | if (direct) { 101 | // Coordinate p = new Coordinate(val1.get(0), val1.get(1)); 102 | // DistanceOp op = new DistanceOp(this.limits, factory.createPoint(p)); 103 | // Coordinate projected = op.nearestPoints()[0]; 104 | // double distance = op.distance(); 105 | // double orientation = Angle.angle(p, projected); 106 | val1[2] = val0[2] * rangeLength + deltaLength; 107 | // val1.set(3, distance * 2); 108 | val1[3] = val0[3] * rangeHeight + deltaHeight; 109 | // val1.set(5, orientation + Math.PI / 2); 110 | return pt * this.absJacobian[0]; 111 | } else { 112 | val1[2] = (val0[2] - deltaLength) / rangeLength; 113 | val1[3] = (val0[3] - deltaHeight) / rangeHeight; 114 | // var1.set(4, 0.0); 115 | // var1.set(5, 0.0); 116 | return pt * this.absJacobian[1]; 117 | } 118 | } 119 | 120 | // @Override 121 | public double getAbsJacobian(boolean direct) { 122 | return this.absJacobian[direct ? 0 : 1]; 123 | } 124 | 125 | @Override 126 | public int dimension() { 127 | return 4; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/birth/TransformToSurface.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation.birth; 2 | 3 | import java.util.Arrays; 4 | import java.util.Iterator; 5 | 6 | import org.apache.logging.log4j.LogManager; 7 | import org.apache.logging.log4j.Logger; 8 | import org.locationtech.jts.geom.Geometry; 9 | import org.locationtech.jts.geom.GeometryFactory; 10 | 11 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 12 | import fr.ign.cogit.geoxygene.util.conversion.AdapterFactory; 13 | import fr.ign.cogit.simplu3d.rjmcmc.generic.transform.SimplePolygonTransform; 14 | import fr.ign.geometry.transform.PolygonTransform; 15 | import fr.ign.rjmcmc.kernel.Transform; 16 | 17 | /** 18 | * This software is released under the licence CeCILL see LICENSE.TXT 19 | * 20 | * see http://www.cecill.info/ 21 | * 22 | * 23 | * copyright IGN 24 | * @author Brasebin Mickaël 25 | * @version 1.0 26 | **/ 27 | public class TransformToSurface implements Transform { 28 | /** 29 | * Logger. 30 | */ 31 | static Logger LOGGER = LogManager.getLogger(TransformToSurface.class.getName()); 32 | 33 | 34 | private PolygonTransform polygonTransform; 35 | 36 | private double delta[]; 37 | private double mat[]; 38 | private double inv[]; 39 | private double determinant; 40 | private double absDeterminant; 41 | 42 | private GeometryFactory factory = new GeometryFactory(); 43 | 44 | private boolean isValid = false; 45 | 46 | public boolean isValid() { 47 | return isValid; 48 | } 49 | 50 | public TransformToSurface(double[] d, double[] v, IGeometry geom) throws Exception { 51 | Geometry pp = AdapterFactory.toGeometry(factory, geom); 52 | 53 | Iterator testedSnapping = Arrays.asList(0.1, 0.001, 0.0).iterator(); 54 | 55 | while (testedSnapping.hasNext() && !isValid) { 56 | 57 | try { 58 | this.polygonTransform = new PolygonTransform(pp, testedSnapping.next()); 59 | isValid = this.polygonTransform.isValid(); 60 | } catch (Exception e) { 61 | //e.printStackTrace(); 62 | } 63 | 64 | } 65 | 66 | if (!isValid) { 67 | this.polygonTransform = new SimplePolygonTransform(pp); 68 | this.isValid = polygonTransform.isValid(); 69 | 70 | } 71 | 72 | 73 | this.mat = new double[d.length]; 74 | this.delta = new double[d.length]; 75 | this.inv = new double[d.length]; 76 | this.determinant = 1.; 77 | 78 | for (int i = 2; i < d.length; ++i) { 79 | double dvalue = d[i]; 80 | determinant *= dvalue; 81 | mat[i] = dvalue; 82 | inv[i] = 1 / dvalue; 83 | delta[i] = v[i]; 84 | } 85 | this.absDeterminant = 1;// Math.abs(determinant); 86 | } 87 | 88 | 89 | 90 | public double getDeterminant() { 91 | return this.determinant; 92 | } 93 | 94 | @Override 95 | public double apply(boolean direct, double[] val0, double[] val1) { 96 | double pt = this.polygonTransform.apply(direct, val0, val1); 97 | if (direct) { 98 | /* 99 | if (dp == null) { 100 | val1[0] = 0.; 101 | val1[1] = 0.; 102 | } else { 103 | val1[0] = dp.getX(); 104 | val1[1] = dp.getY(); 105 | }*/ 106 | for (int i = 2; i < val1.length; i++) { 107 | val1[i] = val0[i] * mat[i] + delta[i]; 108 | } 109 | return pt * 1; 110 | } else { 111 | 112 | 113 | 114 | /* 115 | if (dp == null) { 116 | val1[0] = 0.; 117 | val1[1] = 0.; 118 | } else { 119 | val1[0] = dp.getX(); 120 | val1[1] = dp.getY(); 121 | }*/ 122 | for (int i = 2; i < val1.length; i++) { 123 | val1[i] = (val0[i] - delta[i]) * inv[i]; 124 | } 125 | return pt *1; 126 | } 127 | } 128 | 129 | // @Override 130 | public double getAbsJacobian(boolean direct) { 131 | if (direct) 132 | return this.absDeterminant; 133 | return 1 / this.absDeterminant; 134 | } 135 | 136 | @Override 137 | public int dimension() { 138 | return this.mat.length; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/birth/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * see http://www.cecill.info/ 8 | * 9 | * 10 | * 11 | * copyright IGN 12 | * 13 | * @author Brasebin Mickaël 14 | * 15 | * @version 1.0 16 | **/ 17 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation.birth; -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * see http://www.cecill.info/ 8 | * 9 | * 10 | * 11 | * copyright IGN 12 | * 13 | * @author Brasebin Mickaël 14 | * 15 | * @version 1.0 16 | **/ 17 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation; -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/cuboid/transformation/parallelCuboid/MoveParallelCuboid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation.parallelCuboid; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | /** 5 | * 6 | * This software is released under the licence CeCILL 7 | * 8 | * see LICENSE.TXT 9 | * 10 | * see http://www.cecill.info/ 11 | * 12 | * 13 | * 14 | * copyright IGN 15 | * 16 | * @author Brasebin Mickaël 17 | * 18 | * @version 1.0 19 | **/ 20 | public class MoveParallelCuboid implements Transform { 21 | 22 | private double amplitudeMove; 23 | 24 | public MoveParallelCuboid(double amplitudeMove) { 25 | this.amplitudeMove = amplitudeMove; 26 | } 27 | 28 | @Override 29 | public double apply(boolean direct, double[] val0, double[] val1) { 30 | 31 | double dx = val0[4]; 32 | double dy = val0[5]; 33 | val1[0] = val0[0] + (0.5 - dx) * amplitudeMove; 34 | val1[1] = val0[1] + (0.5 - dy) * amplitudeMove; 35 | val1[2] = val0[2]; 36 | val1[3] = val0[3]; 37 | 38 | val1[4] = 1 - dx; 39 | val1[5] = 1 - dy; 40 | return 1; 41 | } 42 | 43 | // @Override 44 | public double getAbsJacobian(boolean direct) { 45 | return 1; 46 | } 47 | 48 | @Override 49 | public int dimension() { 50 | return 6; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/energy/CompacityCollectionEnergy.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.energy; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | 6 | import fr.ign.cogit.geoxygene.api.feature.IFeature; 7 | import fr.ign.cogit.geoxygene.api.feature.IFeatureCollection; 8 | import fr.ign.cogit.geoxygene.api.spatial.geomaggr.IMultiSurface; 9 | import fr.ign.cogit.geoxygene.api.spatial.geomprim.IOrientableSurface; 10 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 11 | import fr.ign.cogit.geoxygene.convert.FromGeomToSurface; 12 | import fr.ign.cogit.geoxygene.feature.DefaultFeature; 13 | import fr.ign.cogit.geoxygene.feature.FT_FeatureCollection; 14 | import fr.ign.cogit.geoxygene.sig3d.convert.transform.Extrusion2DObject; 15 | import fr.ign.cogit.geoxygene.sig3d.model.citygml.building.CG_Building; 16 | import fr.ign.cogit.geoxygene.util.attribute.AttributeManager; 17 | import fr.ign.cogit.simplu3d.model.AbstractBuilding; 18 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 19 | import fr.ign.cogit.simplu3d.rjmcmc.generic.object.ISimPLU3DPrimitive; 20 | import fr.ign.cogit.simplu3d.util.JTS; 21 | import fr.ign.cogit.simplu3d.util.merge.MergeCuboid; 22 | import fr.ign.cogit.simplu3d.util.merge.SDPCalc; 23 | import fr.ign.cogit.simplu3d.util.merge.SDPCalc.GeomHeightPair; 24 | import fr.ign.rjmcmc.energy.CollectionEnergy; 25 | import fr.ign.rjmcmc.energy.UnaryEnergy; 26 | 27 | 28 | public class CompacityCollectionEnergy implements CollectionEnergy { 29 | 30 | public CompacityCollectionEnergy() { 31 | // TODO Auto-generated constructor stub 32 | } 33 | 34 | 35 | @Override 36 | public double getValue(Collection lili) { 37 | // TODO Auto-generated method stub 38 | 39 | if(lili.size()==0) { 40 | System.out.println("CompacityCollectionEnergy : LISTE VIDE !!!"); 41 | } 42 | 43 | //merging cuboids of the list 44 | MergeCuboid merg = new MergeCuboid(); 45 | //converting lili to a IfeatureCollection 46 | IFeatureCollection featColl_Lili = new FT_FeatureCollection<>(); 47 | for(T l:lili) { 48 | featColl_Lili.add((Cuboid)l); 49 | } 50 | 51 | Double surfaceExterieure = 0.0 ; 52 | if(featColl_Lili.size()>1) { 53 | // merge and give value to surface attribut of merg object 54 | merg.mergeAGroupOfCuboid(featColl_Lili, 0, 0.05, 0.001); 55 | surfaceExterieure = merg.getSurface(); 56 | System.out.println("surface externe : " + surfaceExterieure); 57 | 58 | } 59 | else { 60 | 61 | Cuboid cucu = (Cuboid)featColl_Lili.get(0); 62 | //surfaceExterieure = cucu.getExternalSurfaceWithoutFloor(); 63 | } 64 | 65 | 66 | //pour créer la liste de paires /hauteurs 67 | SDPCalc sdp = new SDPCalc(); 68 | sdp.process((List)lili); 69 | List> pairesGeomHeight = sdp.getGeometryPairByGroup(); 70 | 71 | 72 | Double volume = 0.0 ; 73 | 74 | for (List geomPairs : pairesGeomHeight) { 75 | for (GeomHeightPair g : geomPairs) { 76 | 77 | IGeometry jtsGeom = JTS.fromJTS(g.geom); 78 | 79 | if (jtsGeom == null || jtsGeom.coord().isEmpty()) { 80 | continue; 81 | } 82 | 83 | IMultiSurface os = FromGeomToSurface.convertMSGeom(jtsGeom); 84 | 85 | for (IOrientableSurface osTemp : os) { 86 | if (osTemp.area() < 0.01) { 87 | continue; 88 | } 89 | IGeometry extruded = Extrusion2DObject.convertFromGeometry(osTemp, 0, g.height); 90 | IMultiSurface finalOs = FromGeomToSurface.convertMSGeom(extruded); 91 | IFeature feat = new DefaultFeature(finalOs); 92 | Double contributionVolume = feat.getGeom().area() * g.height; 93 | volume += contributionVolume ; 94 | } 95 | 96 | } 97 | 98 | } 99 | 100 | 101 | 102 | // formule approchée : 3.83 * Volume ^2/3 / Aire 103 | return (2 * Math.PI * Math.pow(3. / (2 * Math.PI), 2.0 / 3.0) * Math.pow(volume, 2. / 3.) / surfaceExterieure); 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/energy/DifferenceVolumeUnaryEnergy.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.energy; 2 | 3 | import org.locationtech.jts.geom.Geometry; 4 | 5 | import fr.ign.cogit.simplu3d.rjmcmc.generic.object.ISimPLU3DPrimitive; 6 | import fr.ign.rjmcmc.energy.UnaryEnergy; 7 | 8 | /** 9 | * 10 | * This software is released under the licence CeCILL 11 | * 12 | * see LICENSE.TXT 13 | * 14 | * see http://www.cecill.info/ 15 | * 16 | * 17 | * 18 | * copyright IGN 19 | * 20 | * @author Brasebin Mickaël 21 | * 22 | * @version 1.0 23 | **/ 24 | public class DifferenceVolumeUnaryEnergy implements UnaryEnergy { 25 | Geometry bpu; 26 | 27 | public DifferenceVolumeUnaryEnergy(Geometry p) { 28 | this.bpu = p; 29 | } 30 | 31 | @Override 32 | public double getValue(T t) { 33 | 34 | Geometry difference = t.toGeometry().difference(this.bpu); 35 | double height = t.getHeight(); 36 | return difference.getArea() * height; 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/energy/IntersectionVolumeBinaryEnergy.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.energy; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 4 | import fr.ign.cogit.simplu3d.rjmcmc.generic.object.ISimPLU3DPrimitive; 5 | import fr.ign.rjmcmc.energy.BinaryEnergy; 6 | 7 | /** 8 | * 9 | * This software is released under the licence CeCILL 10 | * 11 | * see LICENSE.TXT 12 | * 13 | * see http://www.cecill.info/ 14 | * 15 | * 16 | * 17 | * copyright IGN 18 | * 19 | * @author Brasebin Mickaël 20 | * 21 | * @version 1.0 22 | **/ 23 | public class IntersectionVolumeBinaryEnergy 24 | implements BinaryEnergy { 25 | public IntersectionVolumeBinaryEnergy() { 26 | } 27 | 28 | @Override 29 | public double getValue(T t, T u) { 30 | 31 | double areaInter; 32 | if (t instanceof Cuboid && u instanceof Cuboid) { 33 | areaInter = t.intersectionArea(u); 34 | } else { 35 | areaInter = t.intersectionArea(u); 36 | } 37 | 38 | return areaInter * Math.min(t.getHeight(), u.getHeight()); 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/energy/VolumeUnaryEnergy.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.energy; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.generic.object.ISimPLU3DPrimitive; 4 | import fr.ign.rjmcmc.energy.UnaryEnergy; 5 | 6 | /** 7 | * 8 | * This software is released under the licence CeCILL 9 | * 10 | * see LICENSE.TXT 11 | * 12 | * see http://www.cecill.info/ 13 | * 14 | * 15 | * 16 | * copyright IGN 17 | * 18 | * @author Brasebin Mickaël 19 | * 20 | * @version 1.0 21 | **/ 22 | public class VolumeUnaryEnergy implements UnaryEnergy { 23 | 24 | @Override 25 | public double getValue(T t) { 26 | 27 | return t.getVolume(); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/object/ISimPLU3DPrimitive.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.object; 2 | 3 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 4 | import fr.ign.geometry.Primitive; 5 | 6 | public interface ISimPLU3DPrimitive extends Primitive { 7 | 8 | public double getHeight(); 9 | 10 | public double getVolume(); 11 | 12 | public IGeometry generated3DGeom(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/optimizer/DefaultSimPLU3DOptimizer.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.optimizer; 2 | 3 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 4 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 5 | import fr.ign.cogit.simplu3d.rjmcmc.generic.object.ISimPLU3DPrimitive; 6 | import fr.ign.cogit.simplu3d.rjmcmc.generic.visitor.CountVisitor; 7 | import fr.ign.cogit.simplu3d.util.SimpluParameters; 8 | import fr.ign.mpp.configuration.BirthDeathModification; 9 | import fr.ign.mpp.configuration.GraphConfiguration; 10 | import fr.ign.simulatedannealing.endtest.CompositeEndTest; 11 | import fr.ign.simulatedannealing.endtest.EndTest; 12 | import fr.ign.simulatedannealing.endtest.MaxIterationEndTest; 13 | import fr.ign.simulatedannealing.endtest.StabilityEndTest; 14 | import fr.ign.simulatedannealing.schedule.GeometricSchedule; 15 | import fr.ign.simulatedannealing.schedule.Schedule; 16 | import fr.ign.simulatedannealing.temperature.SimpleTemperature; 17 | 18 | 19 | public abstract class DefaultSimPLU3DOptimizer implements ISimPLU3DOptimizer { 20 | 21 | protected double coeffDec = Double.NaN; 22 | protected double deltaConf = Double.NaN; 23 | protected double minLengthBox = Double.NaN; 24 | protected double maxLengthBox = Double.NaN; 25 | protected double minWidthBox = Double.NaN; 26 | protected double maxWidthBox = Double.NaN; 27 | protected double energyCreation = Double.NaN; 28 | protected IGeometry samplingSurface = null; 29 | 30 | public void setSamplingSurface(IGeometry geom) { 31 | samplingSurface = geom; 32 | } 33 | 34 | public void setEnergyCreation(double energyCreation) { 35 | this.energyCreation = energyCreation; 36 | } 37 | 38 | public void setMinLengthBox(double minLengthBox) { 39 | this.minLengthBox = minLengthBox; 40 | } 41 | 42 | public void setMaxLengthBox(double maxLengthBox) { 43 | this.maxLengthBox = maxLengthBox; 44 | } 45 | 46 | public void setMinWidthBox(double minWidthBox) { 47 | this.minWidthBox = minWidthBox; 48 | } 49 | 50 | public void setMaxWidthBox(double maxWidthBox) { 51 | this.maxWidthBox = maxWidthBox; 52 | } 53 | 54 | public void setCoeffDec(double coeffDec) { 55 | this.coeffDec = coeffDec; 56 | } 57 | 58 | public void setDeltaConf(double deltaConf) { 59 | this.deltaConf = deltaConf; 60 | } 61 | 62 | public EndTest create_end_test(SimpluParameters p) { 63 | double loc_deltaconf = Double.isNaN(this.deltaConf) ? p.getDouble("delta") : this.deltaConf; 64 | String option = p.getString("end_test_type").toLowerCase(); 65 | switch (option) { 66 | case "absolute": return new MaxIterationEndTest(p.getInteger("absolute_nb_iter")); 67 | case "relative": 68 | return new StabilityEndTest(p.getInteger("relative_nb_iter"), loc_deltaconf); 69 | case "composite": 70 | default: 71 | EndTest abs = new MaxIterationEndTest(p.getInteger("absolute_nb_iter")); 72 | EndTest rel = new StabilityEndTest(p.getInteger("relative_nb_iter"), loc_deltaconf); 73 | return new CompositeEndTest(abs,rel); 74 | } 75 | } 76 | 77 | protected CountVisitor, BirthDeathModification> countV = null; 78 | 79 | public int getCount() { 80 | return countV.getCount(); 81 | } 82 | 83 | public Schedule create_schedule(SimpluParameters p) { 84 | double coefDef = (Double.isNaN(this.coeffDec)) ? p.getDouble("deccoef") : this.coeffDec; 85 | return new GeometricSchedule(new SimpleTemperature(p.getDouble("temp")), coefDef); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/optimizer/ISimPLU3DOptimizer.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.optimizer; 2 | 3 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 4 | import fr.ign.cogit.simplu3d.rjmcmc.generic.object.ISimPLU3DPrimitive; 5 | 6 | public interface ISimPLU3DOptimizer { 7 | 8 | public void setSamplingSurface(IGeometry geom); 9 | 10 | public void setEnergyCreation(double energyCreation); 11 | 12 | public void setMinLengthBox(double minLengthBox); 13 | 14 | public void setMaxLengthBox(double maxLengthBox); 15 | 16 | public void setMinWidthBox(double minWidthBox); 17 | 18 | public void setMaxWidthBox(double maxWidthBox); 19 | 20 | public void setCoeffDec(double coeffDec); 21 | 22 | public void setDeltaConf(double deltaConf); 23 | 24 | } -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/transform/SimplePolygonTransform.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.transform; 2 | 3 | import org.locationtech.jts.geom.Coordinate; 4 | import org.locationtech.jts.geom.Geometry; 5 | import org.locationtech.jts.geom.MultiPolygon; 6 | import org.locationtech.jts.geom.Point; 7 | import org.locationtech.jts.geom.Polygon; 8 | 9 | import fr.ign.geometry.transform.PolygonTransform; 10 | 11 | public class SimplePolygonTransform extends PolygonTransform { 12 | MultiPolygon polygon; 13 | 14 | double xmin, ymin; 15 | double width, height; 16 | 17 | double totalArea; 18 | 19 | private boolean isValid = true; 20 | 21 | public SimplePolygonTransform(Geometry p) { 22 | super(); 23 | if (Polygon.class.isInstance(p)) { 24 | this.polygon = p.getFactory().createMultiPolygon(new Polygon[] { (Polygon) p }); 25 | } else { 26 | if (MultiPolygon.class.isInstance(p)) { 27 | this.polygon = (MultiPolygon) p; 28 | } else { 29 | throw new IllegalArgumentException( 30 | "Argument should be of type Polygon or MultiPolygon but was " + p.getClass()); 31 | } 32 | } 33 | 34 | totalArea = polygon.getArea(); 35 | 36 | if (polygon.isEmpty() || polygon.getArea() == 0) { 37 | isValid = false; 38 | return; 39 | } 40 | 41 | Geometry enveloppe = polygon.getEnvelope(); 42 | if (enveloppe.isEmpty() || enveloppe.getDimension() != 2) { 43 | isValid = false; 44 | return; 45 | } 46 | 47 | 48 | 49 | Coordinate minPoint = enveloppe.getCoordinates()[0]; 50 | Coordinate maxPoint = enveloppe.getCoordinates()[2]; 51 | 52 | xmin = minPoint.x; 53 | ymin = minPoint.y; 54 | 55 | width = maxPoint.x - xmin; 56 | height = maxPoint.y - ymin; 57 | 58 | isValid = true; 59 | 60 | } 61 | 62 | public boolean isValid() { 63 | return isValid; 64 | } 65 | 66 | @Override 67 | public double apply(boolean direct, double[] val0, double[] val1) { 68 | // 69 | if (direct) { 70 | double s = val0[0]; 71 | double t = val0[1]; 72 | 73 | boolean contains = false; 74 | 75 | double x = 0; 76 | double y = 0; 77 | 78 | for (int i = 0; i < 100000; i++) { 79 | 80 | x = xmin + s * width; 81 | y = ymin + t * height; 82 | 83 | Geometry point = polygon.getFactory().createPoint(new Coordinate(x, y)); 84 | contains = polygon.contains(point); 85 | if (contains) { 86 | break; 87 | } 88 | 89 | s = Math.random(); 90 | t = Math.random(); 91 | 92 | } 93 | 94 | val0[0] = s; 95 | val0[1] = t; 96 | 97 | val1[0] = x; 98 | val1[1] = y; 99 | 100 | if (!contains) { 101 | return 0; 102 | } 103 | 104 | return 1. / totalArea; 105 | } 106 | 107 | double s = val0[0]; 108 | double t = val0[1]; 109 | 110 | Point point = polygon.getFactory().createPoint(new Coordinate(s, t)); 111 | 112 | boolean contains = polygon.contains(point); 113 | 114 | if (!contains) { 115 | return 0; 116 | } 117 | 118 | val1[0] = (s - xmin) / width; 119 | val1[1] = (t - ymin) / height; 120 | return totalArea; 121 | } 122 | 123 | // @Override 124 | public double getAbsJacobian(boolean direct) { 125 | return (direct) ? 1 / totalArea : totalArea; 126 | } 127 | 128 | @Override 129 | public int dimension() { 130 | return 2; 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/visitor/CSVendStats.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.visitor; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.nio.charset.StandardCharsets; 7 | import java.nio.file.Files; 8 | import java.nio.file.Path; 9 | import java.nio.file.Paths; 10 | import java.nio.file.StandardOpenOption; 11 | 12 | import fr.ign.mpp.configuration.ListConfiguration; 13 | import fr.ign.rjmcmc.configuration.Modification; 14 | import fr.ign.rjmcmc.kernel.SimpleObject; 15 | import fr.ign.rjmcmc.sampler.Sampler; 16 | import fr.ign.simulatedannealing.temperature.Temperature; 17 | import fr.ign.simulatedannealing.visitor.Visitor; 18 | /** 19 | * 20 | * This software is released under the licence CeCILL 21 | * 22 | * see LICENSE.TXT 23 | * 24 | * see http://www.cecill.info/ 25 | * 26 | * 27 | * 28 | * copyright IGN 29 | * 30 | * @author Brasebin Mickaël 31 | * 32 | * @version 1.0 33 | **/ 34 | public class CSVendStats, M extends Modification> 35 | implements Visitor { 36 | // private int dump; 37 | // private int save; 38 | private int iter; 39 | private BufferedWriter writer; 40 | private String textSeparator = ";"; 41 | 42 | public CSVendStats(String fileName) { 43 | 44 | try { 45 | 46 | File f = new File(fileName); 47 | 48 | if (!f.exists()) { 49 | f.createNewFile(); 50 | } 51 | 52 | Path path = Paths.get(fileName); 53 | 54 | writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8, 55 | StandardOpenOption.APPEND); 56 | } catch (IOException e) { 57 | // TODO Auto-generated catch block 58 | e.printStackTrace(); 59 | } 60 | } 61 | 62 | @Override 63 | public void init(int dump, int s) { 64 | this.iter = 0; 65 | // this.dump = dump; 66 | // this.save = s; 67 | } 68 | 69 | @Override 70 | public void begin(C config, Sampler sampler, Temperature t) { 71 | 72 | } 73 | 74 | @Override 75 | public void end(C config, Sampler sampler, Temperature t) { 76 | try { 77 | doWrite(config, sampler); 78 | writer.flush(); 79 | writer.close(); 80 | } catch (IOException e) { 81 | // TODO Auto-generated catch block 82 | e.printStackTrace(); 83 | } 84 | 85 | } 86 | 87 | String formatInt = "%1$-10d"; 88 | 89 | double energyMoy = 0; 90 | 91 | private long currentTime; 92 | 93 | @Override 94 | public void visit(C config, Sampler sampler, Temperature t) { 95 | 96 | if (iter == 0) { 97 | currentTime = System.currentTimeMillis(); 98 | } 99 | 100 | ++iter; 101 | 102 | } 103 | 104 | public void doWrite(C config, Sampler sampler) { 105 | 106 | StringBuffer sB = new StringBuffer(); 107 | 108 | sB.append(iter); 109 | sB.append(textSeparator); 110 | sB.append((System.currentTimeMillis() - currentTime) / 1000); 111 | sB.append(textSeparator); 112 | 113 | sB.append(config.size()); 114 | sB.append(textSeparator); 115 | 116 | sB.append(config.getEnergy()); 117 | sB.append(textSeparator); 118 | 119 | try { 120 | writer.append(sB.toString()); 121 | writer.newLine(); 122 | } catch (IOException e) { 123 | // TODO Auto-generated catch block 124 | e.printStackTrace(); 125 | } 126 | 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/visitor/CSVvisitor.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.visitor; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.nio.charset.StandardCharsets; 6 | import java.nio.file.Files; 7 | import java.nio.file.Path; 8 | import java.nio.file.Paths; 9 | import java.nio.file.StandardOpenOption; 10 | 11 | import fr.ign.mpp.configuration.ListConfiguration; 12 | import fr.ign.rjmcmc.configuration.Modification; 13 | import fr.ign.rjmcmc.kernel.SimpleObject; 14 | import fr.ign.rjmcmc.sampler.Sampler; 15 | import fr.ign.simulatedannealing.temperature.Temperature; 16 | import fr.ign.simulatedannealing.visitor.Visitor; 17 | /** 18 | * 19 | * This software is released under the licence CeCILL 20 | * 21 | * see LICENSE.TXT 22 | * 23 | * see http://www.cecill.info/ 24 | * 25 | * 26 | * 27 | * copyright IGN 28 | * 29 | * @author Brasebin Mickaël 30 | * 31 | * @version 1.0 32 | **/ 33 | public class CSVvisitor, M extends Modification> implements Visitor { 34 | private int dump; 35 | private int save; 36 | private int iter; 37 | private BufferedWriter writer; 38 | private String textSeparator = ";"; 39 | 40 | public CSVvisitor(String fileName) { 41 | 42 | Path path = Paths.get(fileName); 43 | try { 44 | writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8, 45 | StandardOpenOption.CREATE); 46 | } catch (IOException e) { 47 | // TODO Auto-generated catch block 48 | e.printStackTrace(); 49 | } 50 | } 51 | 52 | @Override 53 | public void init(int dump, int s) { 54 | this.iter = 0; 55 | this.dump = dump; 56 | this.save = s; 57 | } 58 | 59 | @Override 60 | public void begin(C config, Sampler sampler, Temperature t) { 61 | 62 | String s = "Iteration" + textSeparator + "NBCube" + textSeparator 63 | + "ENERGIE" + textSeparator + "ENERGIE_MOY" + textSeparator 64 | + "NB_FALSE"; 65 | 66 | try { 67 | writer.append(s); 68 | writer.newLine(); 69 | } catch (IOException e) { 70 | // TODO Auto-generated catch block 71 | e.printStackTrace(); 72 | } 73 | 74 | } 75 | 76 | @Override 77 | public void end(C config, Sampler sampler, Temperature t) { 78 | try { 79 | writer.flush(); 80 | writer.close(); 81 | } catch (IOException e) { 82 | // TODO Auto-generated catch block 83 | e.printStackTrace(); 84 | } 85 | 86 | } 87 | 88 | String formatInt = "%1$-10d"; 89 | 90 | double energyMoy = 0; 91 | 92 | @Override 93 | public void visit(C config, Sampler sampler, Temperature t) { 94 | 95 | ++iter; 96 | 97 | energyMoy = (iter - 1) * energyMoy / iter + config.getEnergy() / iter; 98 | 99 | if ((dump > 0) && (iter % dump == 0)) { 100 | doWrite(config, sampler); 101 | } 102 | 103 | if ((dump > 0) && (iter % save == 0)) { 104 | try { 105 | writer.flush(); 106 | } catch (IOException e) { 107 | // TODO Auto-generated catch block 108 | e.printStackTrace(); 109 | } 110 | } 111 | 112 | } 113 | 114 | public void doWrite(C config, Sampler sampler) { 115 | 116 | StringBuffer sB = new StringBuffer(); 117 | 118 | sB.append(iter); 119 | sB.append(textSeparator); 120 | sB.append(config.size()); 121 | sB.append(textSeparator); 122 | 123 | sB.append(config.getEnergy()); 124 | sB.append(textSeparator); 125 | 126 | sB.append(energyMoy); 127 | sB.append(textSeparator); 128 | 129 | try { 130 | writer.append(sB.toString()); 131 | writer.newLine(); 132 | } catch (IOException e) { 133 | // TODO Auto-generated catch block 134 | e.printStackTrace(); 135 | } 136 | 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/visitor/CountVisitor.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.visitor; 2 | 3 | import fr.ign.rjmcmc.configuration.Configuration; 4 | import fr.ign.rjmcmc.configuration.Modification; 5 | import fr.ign.rjmcmc.sampler.Sampler; 6 | import fr.ign.simulatedannealing.temperature.Temperature; 7 | import fr.ign.simulatedannealing.visitor.Visitor; 8 | /** 9 | * 10 | * This software is released under the licence CeCILL 11 | * 12 | * see LICENSE.TXT 13 | * 14 | * see http://www.cecill.info/ 15 | * 16 | * 17 | * 18 | * copyright IGN 19 | * 20 | * @author Brasebin Mickaël 21 | * 22 | * @version 1.0 23 | **/ 24 | public class CountVisitor, M extends Modification> implements Visitor { 25 | 26 | private int count = 0; 27 | 28 | public CountVisitor() { 29 | 30 | } 31 | 32 | @Override 33 | public void init(int d, int save) { 34 | 35 | } 36 | 37 | @Override 38 | public void begin(C config, Sampler sampler, Temperature t) { 39 | } 40 | 41 | @Override 42 | public void end(C config, Sampler sampler, Temperature t) { 43 | 44 | } 45 | 46 | @Override 47 | public void visit(C config, Sampler sampler, Temperature t) { 48 | count++; 49 | } 50 | 51 | public int getCount() { 52 | return count; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/visitor/PrepareVisitors.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.visitor; 2 | 3 | import java.awt.Color; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import fr.ign.cogit.geoxygene.api.spatial.coordgeom.IDirectPosition; 8 | import fr.ign.cogit.geoxygene.contrib.geometrie.Vecteur; 9 | import fr.ign.cogit.geoxygene.spatial.coordgeom.DirectPosition; 10 | import fr.ign.cogit.simplu3d.model.Environnement; 11 | import fr.ign.cogit.simplu3d.rjmcmc.generic.object.ISimPLU3DPrimitive; 12 | import fr.ign.cogit.simplu3d.util.SimpluParameters; 13 | import fr.ign.mpp.configuration.BirthDeathModification; 14 | import fr.ign.mpp.configuration.GraphConfiguration; 15 | import fr.ign.simulatedannealing.visitor.CompositeVisitor; 16 | import fr.ign.simulatedannealing.visitor.OutputStreamVisitor; 17 | import fr.ign.simulatedannealing.visitor.Visitor; 18 | 19 | public class PrepareVisitors { 20 | 21 | private List, BirthDeathModification>> lSupplementaryVisitors = new ArrayList<>(); 22 | 23 | private Environnement env; 24 | 25 | public PrepareVisitors(Environnement env){ 26 | this.env = env; 27 | } 28 | 29 | public PrepareVisitors(Environnement env,List, BirthDeathModification>> lSupplementaryVisitors) { 30 | this(env); 31 | this.lSupplementaryVisitors = lSupplementaryVisitors; 32 | } 33 | 34 | 35 | CountVisitor, BirthDeathModification> countV; 36 | 37 | public CountVisitor, BirthDeathModification> getCountV() { 38 | return countV; 39 | } 40 | 41 | public CompositeVisitor, BirthDeathModification> prepare(SimpluParameters p, int id) { 42 | List, BirthDeathModification>> list = new ArrayList<>(); 43 | 44 | list.addAll(lSupplementaryVisitors); 45 | 46 | if (p.getBoolean("outputstreamvisitor")) { 47 | Visitor, BirthDeathModification> visitor = new OutputStreamVisitor<>(System.out); 48 | list.add(visitor); 49 | } 50 | 51 | if (p.getBoolean("shapefilewriter")) { 52 | ShapefileVisitor, BirthDeathModification> shpVisitor = new ShapefileVisitor<>( 53 | p.get("result").toString() + "result"); 54 | list.add(shpVisitor); 55 | } 56 | 57 | if (p.getBoolean("visitorviewer")) { 58 | Color c = new Color(p.getInteger("filmvisitorr"), p.getInteger("filmvisitorg"), 59 | 60 | p.getInteger("filmvisitorb")); 61 | 62 | ViewerVisitor, BirthDeathModification> visitorViewer = new ViewerVisitor<>(env,"" + id, p,c); 63 | list.add(visitorViewer); 64 | } 65 | 66 | if (p.getBoolean("statsvisitor")) { 67 | StatsVisitor, BirthDeathModification> statsViewer = new StatsVisitor<>( 68 | "Énergie"); 69 | list.add(statsViewer); 70 | } 71 | 72 | if (p.getBoolean("filmvisitor")) { 73 | IDirectPosition dpCentre = new DirectPosition(p.getDouble("filmvisitorx"), p.getDouble("filmvisitory"), 74 | p.getDouble("filmvisitorz")); 75 | 76 | Vecteur viewTo = new Vecteur(p.getDouble("filmvisitorvectx"), p.getDouble("filmvisitorvecty"), 77 | p.getDouble("filmvisitorvectz") 78 | 79 | ); 80 | 81 | Color c = new Color(p.getInteger("filmvisitorr"), p.getInteger("filmvisitorg"), 82 | 83 | p.getInteger("filmvisitorb")); 84 | 85 | FilmVisitor, BirthDeathModification> visitorViewerFilmVisitor = new FilmVisitor<>( 86 | dpCentre, viewTo, p.getString("result"), c, p,env); 87 | list.add(visitorViewerFilmVisitor); 88 | } 89 | 90 | if (p.getBoolean("csvvisitorend")) { 91 | String fileName = p.get("result").toString() + p.get("csvfilenamend"); 92 | CSVendStats, BirthDeathModification> statsViewer = new CSVendStats<>(fileName); 93 | list.add(statsViewer); 94 | } 95 | if (p.getBoolean("csvvisitor")) { 96 | String fileName = p.get("result").toString() + p.get("csvfilename"); 97 | CSVvisitor, BirthDeathModification> statsViewer = new CSVvisitor<>(fileName); 98 | list.add(statsViewer); 99 | } 100 | 101 | countV = new CountVisitor<>(); 102 | list.add(countV); 103 | 104 | 105 | CompositeVisitor, BirthDeathModification> mVisitor = new CompositeVisitor<>(list); 106 | 107 | init_visitor(p, mVisitor); 108 | 109 | return mVisitor; 110 | } 111 | 112 | // Initialisation des visiteurs 113 | // nbdump => affichage dans la console 114 | // nbsave => sauvegarde en shapefile 115 | void init_visitor(SimpluParameters p, Visitor, BirthDeathModification> v) { 116 | v.init(p.getInteger("nbdump"), p.getInteger("nbsave")); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/visitor/ShapefileVisitor.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.generic.visitor; 2 | 3 | 4 | 5 | import fr.ign.cogit.geoxygene.api.feature.IFeature; 6 | import fr.ign.cogit.geoxygene.api.feature.IFeatureCollection; 7 | import fr.ign.cogit.geoxygene.api.spatial.geomaggr.IMultiSurface; 8 | import fr.ign.cogit.geoxygene.api.spatial.geomprim.IOrientableSurface; 9 | import fr.ign.cogit.geoxygene.convert.FromGeomToSurface; 10 | import fr.ign.cogit.geoxygene.feature.DefaultFeature; 11 | import fr.ign.cogit.geoxygene.feature.FT_FeatureCollection; 12 | import fr.ign.cogit.geoxygene.spatial.geomaggr.GM_MultiSurface; 13 | import fr.ign.cogit.geoxygene.util.attribute.AttributeManager; 14 | import fr.ign.cogit.geoxygene.util.conversion.ShapefileWriter; 15 | import fr.ign.cogit.simplu3d.rjmcmc.generic.object.ISimPLU3DPrimitive; 16 | import fr.ign.mpp.configuration.AbstractBirthDeathModification; 17 | import fr.ign.mpp.configuration.AbstractGraphConfiguration; 18 | import fr.ign.mpp.configuration.GraphVertex; 19 | import fr.ign.rjmcmc.sampler.Sampler; 20 | import fr.ign.simulatedannealing.temperature.Temperature; 21 | import fr.ign.simulatedannealing.visitor.Visitor; 22 | 23 | /** 24 | * 25 | * This software is released under the licence CeCILL 26 | * 27 | * see LICENSE.TXT 28 | * 29 | * see http://www.cecill.info/ 30 | * 31 | * 32 | * 33 | * copyright IGN 34 | * 35 | * @author Brasebin Mickaël 36 | * 37 | * @version 1.0 38 | **/ 39 | public class ShapefileVisitor, M extends AbstractBirthDeathModification> 40 | implements Visitor { 41 | private int save; 42 | private int iter; 43 | private String fileName; 44 | 45 | public ShapefileVisitor(String fileName) { 46 | this.fileName = fileName; 47 | } 48 | 49 | @Override 50 | public void init(int dump, int s) { 51 | this.iter = 0; 52 | this.save = s; 53 | } 54 | 55 | @Override 56 | public void begin(C config, Sampler sampler, Temperature t) { 57 | } 58 | 59 | @Override 60 | public void end(C config, Sampler sampler, Temperature t) { 61 | this.writeShapefile(fileName + "_" + (iter +1 )+ ".shp", config); 62 | } 63 | 64 | @Override 65 | public void visit(C config, Sampler sampler, Temperature t) { 66 | ++iter; 67 | if ((save > 0) && (iter % save == 0)) { 68 | this.writeShapefile(fileName + "_" + iter+ ".shp", config); 69 | } 70 | } 71 | 72 | @SuppressWarnings({ "unchecked" }) 73 | private void writeShapefile(String aFileName, C config) { 74 | 75 | IFeatureCollection featureOut = new FT_FeatureCollection<>(); 76 | 77 | 78 | 79 | for (GraphVertex v : config.getGraph().vertexSet()) { 80 | 81 | 82 | 83 | IMultiSurface iMS = new GM_MultiSurface<>(); 84 | iMS.addAll(FromGeomToSurface.convertGeom(v.getValue().generated3DGeom())); 85 | 86 | IFeature feat = new DefaultFeature(iMS); 87 | AttributeManager.addAttribute(feat, "Energy", v.getEnergy(), "Double"); 88 | AttributeManager.addAttribute(feat, "ToString", v.toString(), "String"); 89 | 90 | featureOut.add(feat); 91 | 92 | } 93 | 94 | ShapefileWriter.write(featureOut, aFileName); 95 | 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/generic/visitor/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * This software is released under the licence CeCILL 4 | * 5 | * see LICENSE.TXT 6 | * 7 | * http://www.cecill.info/ 8 | * 9 | * 10 | * 11 | * copyright IGN 12 | * 13 | * @author Brasebin Mickaël 14 | * 15 | * @version 1.0 16 | **/ 17 | 18 | package fr.ign.cogit.simplu3d.rjmcmc.generic.visitor; -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/paramshp/builder/CuboidRoofedBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.paramshp.builder; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.paramshp.geometry.impl.CuboidRoofed; 4 | import fr.ign.mpp.kernel.ObjectBuilder; 5 | 6 | public class CuboidRoofedBuilder implements ObjectBuilder { 7 | 8 | @Override 9 | public CuboidRoofed build(double[] val) { 10 | return new CuboidRoofed(val[0], val[1], val[2], val[3], val[4], val[5], 11 | val[6], val[7]); 12 | } 13 | 14 | @Override 15 | public void setCoordinates(CuboidRoofed t, double[] val) { 16 | t.setCoordinates(val); 17 | } 18 | 19 | @Override 20 | public int size() { 21 | return 8; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/paramshp/builder/LBuildingWithRoofBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.paramshp.builder; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.paramshp.geometry.impl.LBuildingWithRoof; 4 | import fr.ign.mpp.kernel.ObjectBuilder; 5 | 6 | public class LBuildingWithRoofBuilder implements ObjectBuilder { 7 | 8 | @Override 9 | public LBuildingWithRoof build(double[] val) { 10 | return new LBuildingWithRoof(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7], val[8], val[9]); 11 | } 12 | 13 | @Override 14 | public void setCoordinates(LBuildingWithRoof t, double[] val) { 15 | t.setCoordinates(val); 16 | 17 | } 18 | 19 | @Override 20 | public int size() { 21 | return 10; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/paramshp/geometry/impl/AbstractParallelCuboidRoofed.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.paramshp.geometry.impl; 2 | 3 | import java.util.List; 4 | 5 | public abstract class AbstractParallelCuboidRoofed extends CuboidRoofed { 6 | 7 | public AbstractParallelCuboidRoofed(double centerx, double centery, 8 | double length, double width, double height, double orientation, 9 | double heightT, double deltaFromSide) { 10 | super(centerx, centery, length, width, height, orientation, heightT, 11 | deltaFromSide); 12 | } 13 | 14 | @Override 15 | public Object[] getArray() { 16 | return new Object[] { this.centerx, this.centery, 17 | this.length/* , this.width */, this.height/* , this.orientation */, 18 | this.getHeightT(), this.getDeltaFromSide() }; 19 | } 20 | 21 | @Override 22 | public int size() { 23 | return 6; 24 | } 25 | 26 | @Override 27 | public int hashCode() { 28 | int hashCode = 1; 29 | double[] array = { this.centerx, this.centery, 30 | this.length/* , this.width */, this.orientation/* , this.height */, 31 | this.getHeightT(), this.getDeltaFromSide() }; 32 | for (double e : array) 33 | hashCode = 31 * hashCode + hashCode(e); 34 | return hashCode; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (!(o instanceof AbstractParallelCuboidRoofed)) { 40 | return false; 41 | } 42 | AbstractParallelCuboidRoofed r = (AbstractParallelCuboidRoofed) o; 43 | // return r.equals(o); 44 | return (this.centerx == r.centerx) && (this.centery == r.centery) 45 | /* && (this.width == r.width) */ && (this.length == r.length) 46 | && (this.orientation == r.orientation) && (this.height == r.height) 47 | && this.getHeightT() == r.getHeightT() 48 | && this.getDeltaFromSide() == r.getDeltaFromSide(); 49 | } 50 | 51 | public String toString() { 52 | return "ParallelCuboidRoofed : " + " Centre " + this.centerx + "; " 53 | + this.centery + " hauteur " + this.height + " largeur " + this.width 54 | + " longueur " + this.width + " orientation " + this.orientation; 55 | 56 | } 57 | 58 | @Override 59 | public double[] toArray() { 60 | return new double[] { this.centerx, this.centery, 61 | this.length/* , this.width */, this.height/* , this.orientation */ , 62 | this.getHeightT(), this.getDeltaFromSide() }; 63 | } 64 | 65 | @Override 66 | public void set(List list) { 67 | this.centerx = list.get(0); 68 | this.centery = list.get(1); 69 | this.length = list.get(2); 70 | // this.width = list.get(3); 71 | this.height = list.get(3); 72 | this.setHeightT(list.get(4)); 73 | this.setDeltaFromSide(list.get(4)); 74 | // this.orientation = list.get(5); 75 | this.setNew(true); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/paramshp/geometry/impl/ParallelCuboidRoofed.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.paramshp.geometry.impl; 2 | 3 | public class ParallelCuboidRoofed extends AbstractParallelCuboidRoofed { 4 | 5 | public ParallelCuboidRoofed(double centerx, double centery, double length, 6 | double width, double height, double orientation, double heightT, 7 | double deltaFromSide) { 8 | super(centerx, centery, length, width, height, orientation, heightT, 9 | deltaFromSide); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/paramshp/geometry/impl/ParallelCuboidRoofed2.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.paramshp.geometry.impl; 2 | 3 | public class ParallelCuboidRoofed2 extends AbstractParallelCuboidRoofed { 4 | 5 | public ParallelCuboidRoofed2(double centerx, double centery, double length, 6 | double width, double height, double orientation, double heightT, 7 | double deltaFromSide) { 8 | super(centerx, centery, length, width, height, orientation, heightT, 9 | deltaFromSide); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/paramshp/transform/MoveLShapeBuilding.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.paramshp.transform; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | 5 | public class MoveLShapeBuilding implements Transform { 6 | 7 | private double amplitudeMove; 8 | 9 | public MoveLShapeBuilding(double amplitudeMove) { 10 | this.amplitudeMove = amplitudeMove; 11 | } 12 | 13 | @Override 14 | public double apply(boolean direct, double[] val0, double[] val1) { 15 | 16 | double dx = val0[10]; 17 | double dy = val0[11]; 18 | val1[0] = val0[0] + (0.5 - dx) * amplitudeMove; 19 | val1[1] = val0[1] + (0.5 - dy) * amplitudeMove; 20 | val1[2] = val0[2]; 21 | val1[3] = val0[3]; 22 | val1[4] = val0[4]; 23 | val1[5] = val0[5]; 24 | val1[6] = val0[6]; 25 | val1[7] = val0[7]; 26 | val1[8] = val0[8]; 27 | val1[9] = val0[9]; 28 | 29 | 30 | val1[10] = 1 - dx; 31 | val1[11] = 1 - dy; 32 | return 1; 33 | } 34 | 35 | // @Override 36 | public double getAbsJacobian(boolean direct) { 37 | return 1; 38 | } 39 | 40 | @Override 41 | public int dimension() { 42 | return 12; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/paramshp/transform/MoveRCuboid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.paramshp.transform; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | 5 | public class MoveRCuboid implements Transform { 6 | 7 | private double amplitudeMove; 8 | 9 | public MoveRCuboid(double amplitude) { 10 | this.amplitudeMove = amplitude; 11 | } 12 | 13 | @Override 14 | public int dimension() { 15 | return 10; 16 | } 17 | 18 | @Override 19 | public double apply(boolean direct, double[] val0, double[] val1) { 20 | double dx = val0[8]; 21 | double dy = val0[9]; 22 | val1[0] = val0[0] + (0.5 - dx) * amplitudeMove; 23 | val1[1] = val0[1] + (0.5 - dy) * amplitudeMove; 24 | val1[2] = val0[2]; 25 | val1[3] = val0[3]; 26 | val1[4] = val0[4]; 27 | val1[5] = val0[5]; 28 | val1[6] = val0[6]; 29 | val1[7] = val0[7]; 30 | 31 | val1[8] = 1 - dx; 32 | val1[9] = 1 - dy; 33 | return 1; 34 | } 35 | 36 | public double getAbsJacobian(boolean direct) { 37 | return 1; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/trapezoid/builder/ParallelRightTrapezoidBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.trapezoid.builder; 2 | 3 | import org.locationtech.jts.geom.Coordinate; 4 | import org.locationtech.jts.geom.Geometry; 5 | import org.locationtech.jts.geom.GeometryFactory; 6 | import org.locationtech.jts.geom.LineString; 7 | import org.locationtech.jts.geom.MultiLineString; 8 | import org.locationtech.jts.operation.distance.DistanceOp; 9 | 10 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 11 | import fr.ign.cogit.geoxygene.util.conversion.AdapterFactory; 12 | import fr.ign.cogit.simplu3d.rjmcmc.trapezoid.geometry.ParallelTrapezoid; 13 | import fr.ign.mpp.kernel.ObjectBuilder; 14 | 15 | public class ParallelRightTrapezoidBuilder implements ObjectBuilder { 16 | 17 | GeometryFactory factory; 18 | MultiLineString limits; 19 | double factMult = 10; 20 | 21 | public ParallelRightTrapezoidBuilder(IGeometry[] limits) { 22 | super(); 23 | factory = new GeometryFactory(); 24 | LineString[] lineStrings = new LineString[limits.length]; 25 | for (int i = 0; i < limits.length; i++) { 26 | try { 27 | lineStrings[i] = (LineString) AdapterFactory.toGeometry(factory, limits[i]); 28 | } catch (Exception e) { 29 | // TODO Auto-generated catch block 30 | e.printStackTrace(); 31 | } 32 | } 33 | this.limits = factory.createMultiLineString(lineStrings); 34 | Geometry geom = this.limits.getEnvelope(); 35 | Coordinate coMin = geom.getCoordinates()[0]; 36 | Coordinate coMax = geom.getCoordinates()[3]; 37 | 38 | factMult = DistanceOp.distance(factory.createPoint(coMin), factory.createPoint(coMax)); 39 | 40 | } 41 | 42 | @Override 43 | public ParallelTrapezoid build(double[] val1) { 44 | double a = Math.cos(val1[5]) * val1[3]; 45 | double b = Math.sin(val1[5]) * val1[3]; 46 | /* 47 | * 48 | * RightTrapezoid rt = new RightTrapezoid(val1[0], val1[1], val1[2], 0, 49 | * 0, val1[3], val1[4], val1[5]); 50 | * 51 | * TestParallelRightTrapezoidSampler.trapezoidAfter.add(rt.getGeom()); 52 | */ 53 | 54 | Coordinate p1 = new Coordinate(val1[0] + b, val1[1] - a); 55 | Coordinate p2 = new Coordinate(val1[0] - b, val1[1] + a); 56 | 57 | Coordinate p3 = new Coordinate(p1.x - a * factMult, p1.y - b * factMult); 58 | Coordinate p4 = new Coordinate(p2.x - a * factMult, p2.y - b * factMult); 59 | 60 | Coordinate[] coords1 = new Coordinate[2]; 61 | Coordinate[] coords2 = new Coordinate[2]; 62 | 63 | coords1[0] = p1; 64 | coords1[1] = p3; 65 | 66 | coords2[0] = p2; 67 | coords2[1] = p4; 68 | 69 | Geometry g1 = new GeometryFactory().createLineString(coords1); 70 | Geometry g2 = new GeometryFactory().createLineString(coords2); 71 | 72 | Geometry geom1 = g1.intersection(limits); 73 | Geometry geom2 = g2.intersection(limits); 74 | 75 | /* 76 | * try { 77 | * TestParallelRightTrapezoidSampler.orientationLine.add(JtsGeOxygene. 78 | * makeGeOxygeneGeom(g1)); 79 | * TestParallelRightTrapezoidSampler.orientationLine.add(JtsGeOxygene. 80 | * makeGeOxygeneGeom(g2)); } catch (Exception e) { // TODO 81 | * Auto-generated catch block e.printStackTrace(); } 82 | */ 83 | 84 | double length2 = Double.POSITIVE_INFINITY; 85 | 86 | if (geom1 != null && !geom1.isEmpty()) { 87 | 88 | Coordinate[] cTemp = geom1.getCoordinates(); 89 | 90 | for (int i = 0; i < cTemp.length; i++) { 91 | length2 = Math.min(length2, 92 | DistanceOp.distance(factory.createPoint(p1), factory.createPoint(cTemp[i]))); 93 | } 94 | 95 | } 96 | double length3 = Double.POSITIVE_INFINITY; 97 | 98 | if (geom2 != null && !geom2.isEmpty()) { 99 | 100 | Coordinate[] cTemp = geom2.getCoordinates(); 101 | 102 | for (int i = 0; i < cTemp.length; i++) { 103 | length3 = Math.min(length3, 104 | DistanceOp.distance(factory.createPoint(p2), factory.createPoint(cTemp[i]))); 105 | } 106 | 107 | } 108 | 109 | return new ParallelTrapezoid(val1[0], val1[1], val1[2], length3, length2, val1[3], val1[4], val1[5]); 110 | } 111 | 112 | @Override 113 | public void setCoordinates(ParallelTrapezoid t, double[] val1) { 114 | val1[0] = t.centerx; 115 | val1[1] = t.centery; 116 | val1[2] = t.length1; 117 | // val1[3] = t.length2; 118 | // val1[3] = t.length3; 119 | val1[3] = t.width; 120 | val1[4] = t.height; 121 | val1[5] = t.orientation; 122 | 123 | } 124 | 125 | @Override 126 | public int size() { 127 | return 6; 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/trapezoid/builder/SimpleRightTrapezoidBuilder.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.trapezoid.builder; 2 | 3 | import fr.ign.cogit.simplu3d.rjmcmc.trapezoid.geometry.RightTrapezoid; 4 | import fr.ign.mpp.kernel.ObjectBuilder; 5 | 6 | public class SimpleRightTrapezoidBuilder implements ObjectBuilder { 7 | 8 | public SimpleRightTrapezoidBuilder() { 9 | super(); 10 | } 11 | 12 | @Override 13 | public RightTrapezoid build(double[] val1) { 14 | // TODO Auto-generated method stub 15 | return new RightTrapezoid(val1[0], val1[1], val1[2], val1[3], val1[4], val1[5], val1[6], val1[7]); 16 | } 17 | 18 | @Override 19 | public void setCoordinates(RightTrapezoid t, double[] val1) { 20 | val1[0] = t.centerx; 21 | val1[1] = t.centery; 22 | val1[2] = t.length1; 23 | val1[3] = t.length2; 24 | val1[4] = t.length3; 25 | val1[5] = t.width; 26 | val1[6] = t.height; 27 | val1[7] = t.orientation; 28 | 29 | } 30 | 31 | @Override 32 | public int size() { 33 | // TODO Auto-generated method stub 34 | return 8; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/trapezoid/geometry/ParallelTrapezoid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.trapezoid.geometry; 2 | 3 | import java.util.List; 4 | 5 | import org.locationtech.jts.geom.Coordinate; 6 | import org.locationtech.jts.geom.GeometryFactory; 7 | import org.locationtech.jts.geom.LinearRing; 8 | import org.locationtech.jts.geom.Polygon; 9 | 10 | import fr.ign.cogit.geoxygene.api.spatial.coordgeom.IDirectPosition; 11 | import fr.ign.cogit.geoxygene.contrib.geometrie.Vecteur; 12 | import fr.ign.cogit.geoxygene.spatial.coordgeom.DirectPosition; 13 | 14 | /** 15 | * 16 | * This software is released under the licence CeCILL 17 | * 18 | * see LICENSE.TXT 19 | * 20 | * see http://www.cecill.info/ 21 | * 22 | * 23 | * 24 | * copyright IGN 25 | * 26 | * @author Brasebin Mickaël 27 | * 28 | * @version 1.0 29 | **/ 30 | public class ParallelTrapezoid extends RightTrapezoid { 31 | 32 | public ParallelTrapezoid(double centerx, double centery, double length1, double length2, double length3, double width, 33 | double height, double orientation) { 34 | super(centerx, centery, length1, length2, length3, width, height, orientation); 35 | // TODO Auto-generated constructor stub 36 | } 37 | 38 | @Override 39 | public Object[] getArray() { 40 | return new Object[] { this.centerx, this.centery, this.length1, 41 | /*this.length2, this.length3*/ this.width, this.height, this.orientation }; 42 | } 43 | 44 | @Override 45 | public void set(List list) { 46 | this.centerx = list.get(0); 47 | this.centery = list.get(1); 48 | this.length1 = list.get(2); 49 | // this.length2 = list.get(3); 50 | // this.length3 = list.get(4); 51 | this.width = list.get(3); 52 | this.height = list.get(4); 53 | this.orientation = list.get(5); 54 | this.setNew(true); 55 | 56 | } 57 | 58 | @Override 59 | public int size() { 60 | return 6; 61 | } 62 | 63 | @Override 64 | public double[] toArray() { 65 | return new double[] { this.centerx, this.centery, this.length1, 66 | /* this.length2, this.length3*/ this.width, this.height, this.orientation }; 67 | } 68 | 69 | private static GeometryFactory geomFact = new GeometryFactory(); 70 | 71 | @Override 72 | public Polygon toGeometry() { 73 | 74 | if (geomJTS == null) { 75 | 76 | 77 | Coordinate[] pts = new Coordinate[5]; 78 | double cosOrient = Math.cos(orientation); 79 | double sinOrient = Math.sin(orientation); 80 | double a = cosOrient * length ; 81 | double b = sinOrient * width ; 82 | double c = sinOrient * length; 83 | double d = cosOrient * width; 84 | pts[0] = new Coordinate(this.centerx - a + b, this.centery - c - d, 85 | height); 86 | pts[1] = new Coordinate(this.centerx + a + b, this.centery + c - d, 87 | height); 88 | pts[2] = new Coordinate(this.centerx + a - b, this.centery + c + d, 89 | height); 90 | pts[3] = new Coordinate(this.centerx - a - b, this.centery - c + d, 91 | height); 92 | 93 | 94 | 95 | Vecteur v2 = new Vecteur(pts[3].x - pts[2].x,pts[3].y - pts[2].y); 96 | v2.normalise(); 97 | v2 = v2.multConstante(length + length2); 98 | IDirectPosition dp3 = v2.translate(new DirectPosition(pts[2].x, pts[2].y)); 99 | 100 | 101 | Vecteur v = new Vecteur(pts[0].x - pts[1].x,pts[0].y - pts[1].y); 102 | v.normalise(); 103 | v = v.multConstante(length + length3); 104 | IDirectPosition dp0 = v.translate(new DirectPosition(pts[1].x, pts[1].y)); 105 | 106 | 107 | System.out.println("length + length2" + (length + length2)); 108 | System.out.println("length + length3" + (length + length3)); 109 | 110 | pts[0] = new Coordinate(dp0.getX(), dp0.getY()); 111 | pts[3] = new Coordinate(dp3.getX(), dp3.getY()); 112 | pts[4] = new Coordinate(pts[0]); 113 | 114 | LinearRing ring = geomFact.createLinearRing(pts); 115 | Polygon poly = geomFact.createPolygon(ring, null); 116 | this.geomJTS = poly; 117 | } 118 | return this.geomJTS; 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/trapezoid/geometry/ParallelTrapezoid2.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.trapezoid.geometry; 2 | 3 | import java.util.List; 4 | 5 | import org.locationtech.jts.geom.Coordinate; 6 | import org.locationtech.jts.geom.GeometryFactory; 7 | import org.locationtech.jts.geom.LinearRing; 8 | import org.locationtech.jts.geom.Polygon; 9 | 10 | import fr.ign.cogit.geoxygene.api.spatial.coordgeom.IDirectPosition; 11 | import fr.ign.cogit.geoxygene.api.spatial.geomprim.IOrientableSurface; 12 | import fr.ign.cogit.geoxygene.contrib.geometrie.Vecteur; 13 | import fr.ign.cogit.geoxygene.convert.FromGeomToSurface; 14 | import fr.ign.cogit.geoxygene.spatial.coordgeom.DirectPosition; 15 | 16 | /** 17 | * 18 | * This software is released under the licence CeCILL 19 | * 20 | * see LICENSE.TXT 21 | * 22 | * see http://www.cecill.info/ 23 | * 24 | * 25 | * 26 | * copyright IGN 27 | * 28 | * @author Brasebin Mickaël 29 | * 30 | * @version 1.0 31 | **/ 32 | public class ParallelTrapezoid2 extends RightTrapezoid { 33 | 34 | public double abscisse; 35 | 36 | public ParallelTrapezoid2(double centerx, double centery, double length1, double length2, double length3, 37 | double width, double height, double abscisse) { 38 | super(centerx, centery, length1, length2, length3, width, height, Double.NaN); 39 | this.abscisse = abscisse; 40 | 41 | } 42 | 43 | @Override 44 | public Object[] getArray() { 45 | return new Object[] { this.centerx, this.centery, this.length1, 46 | /* this.length2, this.length3 */ this.width, this.height, this.abscisse }; 47 | } 48 | 49 | @Override 50 | public void set(List list) { 51 | this.centerx = list.get(0); 52 | this.centery = list.get(1); 53 | this.length1 = list.get(2); 54 | // this.length2 = list.get(3); 55 | // this.length3 = list.get(4); 56 | this.width = list.get(3); 57 | this.height = list.get(4); 58 | this.abscisse = list.get(5); 59 | this.setNew(true); 60 | 61 | } 62 | 63 | @Override 64 | public void setCoordinates(double[] val1) { 65 | val1[0] = this.centerx; 66 | val1[1] = this.centery; 67 | val1[2] = this.length1; 68 | // this.length2 = val1[3]; 69 | // this.length3 = val1[4]; 70 | val1[3] = this.width; 71 | val1[4] = this.height; 72 | val1[5] = this.abscisse; 73 | } 74 | 75 | @Override 76 | public int size() { 77 | return 6; 78 | } 79 | 80 | @Override 81 | public double[] toArray() { 82 | return new double[] { this.centerx, this.centery, this.length1, 83 | /* this.length2, this.length3 */ this.width, this.height, this.abscisse }; 84 | } 85 | 86 | private static GeometryFactory geomFact = new GeometryFactory(); 87 | 88 | public double getOrientation() { 89 | return orientation; 90 | } 91 | 92 | public void setOrientation(double orientation) { 93 | this.orientation = orientation; 94 | } 95 | 96 | @Override 97 | public IOrientableSurface getFootprint() { 98 | 99 | return FromGeomToSurface.convertGeom(this.getGeom()).get(0); 100 | 101 | } 102 | 103 | @Override 104 | public Polygon toGeometry() { 105 | 106 | if (geomJTS == null) { 107 | 108 | Coordinate[] pts = new Coordinate[5]; 109 | double cosOrient = Math.cos(this.getOrientation()); 110 | double sinOrient = Math.sin(this.getOrientation()); 111 | double a = cosOrient * (length); 112 | double b = sinOrient * (width/2); 113 | double c = sinOrient * (length); 114 | double d = cosOrient * (width /2); 115 | pts[0] = new Coordinate(this.centerx - a + b, this.centery - c - d, height); 116 | pts[1] = new Coordinate(this.centerx + a + b, this.centery + c - d, height); 117 | pts[2] = new Coordinate(this.centerx + a - b, this.centery + c + d, height); 118 | pts[3] = new Coordinate(this.centerx - a - b, this.centery - c + d, height); 119 | 120 | Vecteur v2 = new Vecteur(pts[3].x - pts[2].x, pts[3].y - pts[2].y); 121 | v2.normalise(); 122 | v2 = v2.multConstante(length + length2); 123 | IDirectPosition dp3 = v2.translate(new DirectPosition(pts[2].x, pts[2].y)); 124 | 125 | Vecteur v = new Vecteur(pts[0].x - pts[1].x, pts[0].y - pts[1].y); 126 | v.normalise(); 127 | v = v.multConstante(length + length3); 128 | IDirectPosition dp0 = v.translate(new DirectPosition(pts[1].x, pts[1].y)); 129 | 130 | // System.out.println("length + length2" + (length + length2)); 131 | // System.out.println("length + length3" + (length + length3)); 132 | 133 | pts[0] = new Coordinate(dp0.getX(), dp0.getY()); 134 | pts[3] = new Coordinate(dp3.getX(), dp3.getY()); 135 | pts[4] = new Coordinate(pts[0]); 136 | 137 | LinearRing ring = geomFact.createLinearRing(pts); 138 | Polygon poly = geomFact.createPolygon(ring, null); 139 | this.geomJTS = poly; 140 | } 141 | return this.geomJTS; 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/trapezoid/transform/ParallelTrapezoidTransform.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.trapezoid.transform; 2 | 3 | import java.util.Arrays; 4 | import java.util.Iterator; 5 | 6 | import org.apache.logging.log4j.LogManager; 7 | import org.apache.logging.log4j.Logger; 8 | import org.locationtech.jts.geom.Geometry; 9 | import org.locationtech.jts.geom.GeometryFactory; 10 | 11 | import fr.ign.cogit.geoxygene.api.spatial.geomroot.IGeometry; 12 | import fr.ign.cogit.geoxygene.util.conversion.AdapterFactory; 13 | import fr.ign.geometry.transform.PolygonTransform; 14 | import fr.ign.rjmcmc.kernel.Transform; 15 | 16 | /** 17 | * 18 | * This software is released under the licence CeCILL 19 | * 20 | * see LICENSE.TXT 21 | * 22 | * see http://www.cecill.info/ 23 | * 24 | * copyright IGN 25 | * 26 | * @version 1.0 27 | **/ 28 | public class ParallelTrapezoidTransform implements Transform { 29 | /** 30 | * Logger. 31 | */ 32 | static Logger LOGGER = LogManager.getLogger(ParallelTrapezoidTransform.class.getName()); 33 | 34 | private double absJacobian[]; 35 | private PolygonTransform polygonTransform; 36 | // private MultiLineString limits; 37 | private GeometryFactory factory = new GeometryFactory(); 38 | 39 | private boolean isValid = false; 40 | 41 | private double deltaLength; 42 | private double deltaHeight; 43 | private double rangeLength; 44 | private double rangeHeight; 45 | private double rangeWidth; 46 | private double rangeOrientation; 47 | private double deltaWidth; 48 | private double deltaOrientation; 49 | 50 | public ParallelTrapezoidTransform(double[] d, double[] v, IGeometry polygon) throws Exception { 51 | this.rangeLength = d[2]; 52 | this.rangeHeight = d[4]; 53 | this.rangeWidth = d[3]; 54 | this.rangeOrientation = d[5]; 55 | this.deltaLength = v[2]; 56 | this.deltaHeight = v[4]; 57 | this.deltaWidth = v[3]; 58 | this.deltaOrientation = v[5]; 59 | 60 | double determinant = rangeLength * rangeHeight * rangeWidth * rangeOrientation; 61 | // LineString[] lineStrings = new LineString[limits.length]; 62 | // for (int i = 0; i < limits.length; i++) { 63 | // lineStrings[i] = (LineString) AdapterFactory.toGeometry(factory, limits[i]); 64 | // } 65 | // this.limits = factory.createMultiLineString(lineStrings); 66 | Geometry pp = AdapterFactory.toGeometry(factory, polygon); 67 | this.polygonTransform = new PolygonTransform(pp, 0.1); 68 | 69 | Iterator testedSnapping = Arrays.asList(0.1, 0.001, 0.0).iterator(); 70 | 71 | while (testedSnapping.hasNext() && !isValid) { 72 | this.polygonTransform = new PolygonTransform(pp, testedSnapping.next()); 73 | isValid = this.polygonTransform.isValid(); 74 | } 75 | 76 | if (isValid) { 77 | this.absJacobian = new double[2]; 78 | this.absJacobian[0] = Math.abs(determinant) * this.polygonTransform.getAbsJacobian(true); 79 | this.absJacobian[1] = Math.abs(1 / determinant) * this.polygonTransform.getAbsJacobian(false); 80 | } 81 | } 82 | 83 | /** 84 | * @return Indicate if the transform is valid (i.e: that the triangulation in 85 | * the PolygonTransform is ok) 86 | * 87 | */ 88 | public boolean isValid() { 89 | return isValid; 90 | } 91 | 92 | @Override 93 | public double apply(boolean direct, double[] val0, double[] val1) { 94 | double pt = this.polygonTransform.apply(direct, val0, val1); 95 | if (direct) { 96 | // Coordinate p = new Coordinate(val1.get(0), val1.get(1)); 97 | // DistanceOp op = new DistanceOp(this.limits, factory.createPoint(p)); 98 | // Coordinate projected = op.nearestPoints()[0]; 99 | // double distance = op.distance(); 100 | // double orientation = Angle.angle(p, projected); 101 | val1[2] = val0[2] * rangeLength + deltaLength; 102 | val1[3] = val0[3] * rangeWidth + deltaWidth; 103 | // val1.set(3, distance * 2); 104 | val1[4] = val0[4] * rangeHeight + deltaHeight; 105 | val1[5] = val0[5] * rangeOrientation + deltaOrientation; 106 | // val1.set(5, orientation + Math.PI / 2); 107 | return pt * this.absJacobian[0]; 108 | } else { 109 | val1[2] = (val0[2] - deltaLength) / rangeLength; 110 | val1[3] = (val0[3] - deltaWidth) / rangeWidth; 111 | val1[4] = (val0[4] - deltaHeight) / rangeHeight; 112 | val1[5] = (val0[5] - deltaOrientation) / rangeOrientation; 113 | // var1.set(4, 0.0); 114 | // var1.set(5, 0.0); 115 | return pt * this.absJacobian[1]; 116 | } 117 | } 118 | 119 | // @Override 120 | public double getAbsJacobian(boolean direct) { 121 | return this.absJacobian[direct ? 0 : 1]; 122 | } 123 | 124 | @Override 125 | public int dimension() { 126 | return 6; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/trapezoid/transformation/MoveParallelRightTrapezoid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.trapezoid.transformation; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | 5 | 6 | /** 7 | * 8 | * This software is released under the licence CeCILL 9 | * 10 | * see LICENSE.TXT 11 | * 12 | * see http://www.cecill.info/ 13 | * 14 | * 15 | * 16 | * copyright IGN 17 | * 18 | * @author Brasebin Mickaël 19 | * 20 | * @version 1.0 21 | **/ 22 | public class MoveParallelRightTrapezoid implements Transform { 23 | 24 | private double amplitudeMove; 25 | 26 | public MoveParallelRightTrapezoid(double amplitudeMove) { 27 | this.amplitudeMove = amplitudeMove; 28 | } 29 | 30 | @Override 31 | public double apply(boolean direct, double[] val0, double[] val1) { 32 | 33 | double dx = val0[5]; 34 | double dy = val0[6]; 35 | val1[0] = val0[0] + (0.5 - dx) * amplitudeMove; 36 | val1[1] = val0[1] + (0.5 - dy) * amplitudeMove; 37 | val1[2] = val0[2]; 38 | val1[3] = val0[3]; 39 | val1[4] = val0[4]; 40 | 41 | val1[5] = 1 - dx; 42 | val1[6] = 1 - dy; 43 | return 1; 44 | } 45 | 46 | // @Override 47 | public double getAbsJacobian(boolean direct) { 48 | return 1; 49 | } 50 | 51 | @Override 52 | public int dimension() { 53 | return 7; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/rjmcmc/trapezoid/transformation/RotateTrapezoid.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.rjmcmc.trapezoid.transformation; 2 | 3 | import fr.ign.rjmcmc.kernel.Transform; 4 | /** 5 | * 6 | * This software is released under the licence CeCILL 7 | * 8 | * see LICENSE.TXT 9 | * 10 | * see http://www.cecill.info/ 11 | * 12 | * 13 | * 14 | * copyright IGN 15 | * 16 | * @author Brasebin Mickaël 17 | * 18 | * @version 1.0 19 | **/ 20 | public class RotateTrapezoid implements Transform { 21 | 22 | private double amplitudeRotate; 23 | 24 | public RotateTrapezoid(double amp) { 25 | amplitudeRotate = amp; 26 | } 27 | 28 | @Override 29 | public double apply(boolean direct, double[] val0, double[] val1) { 30 | 31 | double dor = val0[9]; 32 | double newAngle = val0[8] + (0.5 - dor) * amplitudeRotate; 33 | double modulo = newAngle % (Math.PI); 34 | if (modulo < 0) { 35 | modulo = Math.PI + modulo; 36 | } 37 | val1[0] = val0[0]; 38 | val1[1] = val0[1]; 39 | val1[2] = val0[2]; 40 | val1[3] = val0[3]; 41 | val1[4] = val0[4]; 42 | val1[5] = val0[5]; 43 | val1[6] = val0[6]; 44 | val1[7] = val0[7]; 45 | val1[9] = modulo; 46 | 47 | val1[9] = 1 - dor; 48 | return 1; 49 | } 50 | 51 | // @Override 52 | public double getAbsJacobian(boolean direct) { 53 | return 1; 54 | } 55 | 56 | @Override 57 | public int dimension() { 58 | return 10; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/util/SimpluParameters.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.util; 2 | 3 | public interface SimpluParameters { 4 | 5 | Object get(String name); 6 | 7 | String getString(String name); 8 | 9 | boolean getBoolean(String name); 10 | 11 | double getDouble(String name); 12 | 13 | int getInteger(String name); 14 | 15 | float getFloat(String name); 16 | 17 | void set(String name, Object value); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/util/SimpluParametersJSON.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.util; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.List; 8 | import java.util.Map.Entry; 9 | 10 | import org.json.simple.JSONObject; 11 | import org.json.simple.parser.JSONParser; 12 | import org.json.simple.parser.ParseException; 13 | 14 | public class SimpluParametersJSON implements SimpluParameters { 15 | private JSONObject jsonObject; 16 | 17 | public SimpluParametersJSON(File f) { 18 | JSONParser parser = new JSONParser(); 19 | File file = (f.getName().endsWith(".xml")) ? new File(f.getParentFile(), f.getName().replaceAll(".xml", ".json")) : f; 20 | try { 21 | jsonObject = (JSONObject) parser.parse(new FileReader(file)); 22 | } catch (FileNotFoundException e) { 23 | e.printStackTrace(); 24 | } catch (IOException e) { 25 | e.printStackTrace(); 26 | } catch (ParseException e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | 31 | public SimpluParametersJSON(SimpluParametersJSON p) { 32 | jsonObject = new JSONObject(); 33 | for (Object o : p.jsonObject.entrySet()) { 34 | Entry e = (Entry) o; 35 | jsonObject.put(e.getKey(), e.getValue()); 36 | } 37 | } 38 | 39 | public SimpluParametersJSON(List lf) { 40 | jsonObject = new JSONObject(); 41 | JSONParser parser = new JSONParser(); 42 | for (File f : lf) { 43 | File file = (f.getName().endsWith(".xml")) ? new File(f.getParentFile(), f.getName().replaceAll(".xml", ".json")) : f; 44 | try { 45 | JSONObject jsonObjectForFile = (JSONObject) parser.parse(new FileReader(file)); 46 | jsonObject.putAll(jsonObjectForFile); 47 | } catch (FileNotFoundException e) { 48 | e.printStackTrace(); 49 | } catch (IOException e) { 50 | e.printStackTrace(); 51 | } catch (ParseException e) { 52 | e.printStackTrace(); 53 | } 54 | } 55 | } 56 | 57 | public void add(SimpluParametersJSON p) { 58 | jsonObject.putAll(p.jsonObject); 59 | } 60 | 61 | public Object get(String name) { 62 | return this.jsonObject.get(name); 63 | } 64 | 65 | public String getString(String name) { 66 | return this.jsonObject.getOrDefault(name, "").toString(); 67 | } 68 | 69 | public boolean getBoolean(String name) { 70 | return Boolean.parseBoolean(this.jsonObject.getOrDefault(name, false).toString()); 71 | } 72 | 73 | public double getDouble(String name) { 74 | return Double.parseDouble(this.jsonObject.getOrDefault(name, 0.0D).toString()); 75 | } 76 | 77 | public int getInteger(String name) { 78 | return Integer.parseInt(this.jsonObject.getOrDefault(name, 0).toString()); 79 | } 80 | 81 | public float getFloat(String name) { 82 | return Float.parseFloat(this.jsonObject.getOrDefault(name, 0.0F).toString()); 83 | } 84 | 85 | public void set(String name, Object value) { 86 | this.jsonObject.put(name, value); 87 | } 88 | 89 | public String toString() { 90 | return this.jsonObject.toJSONString(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/util/SimpluParametersPostgis.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.util; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.sql.Statement; 8 | 9 | import org.apache.logging.log4j.LogManager; 10 | import org.apache.logging.log4j.Logger; 11 | 12 | public class SimpluParametersPostgis implements SimpluParameters{ 13 | private final static String PARAMETERS_TABLE = "parameters"; 14 | private final static String PARAMETERS_ID = "id"; 15 | private ResultSet rs; 16 | 17 | public SimpluParametersPostgis(String host, String port, String database, String user, String pw, int id) throws SQLException { 18 | String url = "jdbc:postgresql://" + host + ":" + port + "/" + database; 19 | Connection conn = DriverManager.getConnection(url, user, pw); 20 | Statement s = conn.createStatement(); 21 | String sql = "Select * from " + PARAMETERS_TABLE + " where "+PARAMETERS_ID+" =" + id; 22 | rs = s.executeQuery(sql); 23 | boolean next = rs.next(); 24 | if (!next) { 25 | Logger log = LogManager.getLogger(SimpluParametersPostgis.class); 26 | log.error("No parameters line found"); 27 | System.exit(1); 28 | } 29 | conn.close(); 30 | } 31 | 32 | public Object get(String key) { 33 | try { 34 | return rs.getObject(key); 35 | } catch (SQLException e) { 36 | e.printStackTrace(); 37 | } 38 | return null; 39 | } 40 | 41 | public String getString(String name) { 42 | Object value = this.get(name); 43 | return value == null ? "" : value.toString(); 44 | } 45 | 46 | public boolean getBoolean(String name) { 47 | Object value = this.get(name); 48 | return value != null && Boolean.parseBoolean(value.toString()); 49 | } 50 | 51 | public double getDouble(String name) { 52 | Object value = this.get(name); 53 | return value == null ? 0.0D : Double.parseDouble(value.toString()); 54 | } 55 | 56 | public int getInteger(String name) { 57 | Object value = this.get(name); 58 | return value == null ? 0 : Integer.parseInt(value.toString()); 59 | } 60 | 61 | public float getFloat(String name) { 62 | Object value = this.get(name); 63 | return value == null ? 0.0F : Float.parseFloat(value.toString()); 64 | } 65 | 66 | public void set(String name, Object value) { 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/util/convert/ExportAsFeatureCollection.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.util.convert; 2 | 3 | import fr.ign.cogit.geoxygene.api.feature.IFeature; 4 | import fr.ign.cogit.geoxygene.api.feature.IFeatureCollection; 5 | import fr.ign.cogit.geoxygene.feature.DefaultFeature; 6 | import fr.ign.cogit.geoxygene.feature.FT_FeatureCollection; 7 | import fr.ign.cogit.geoxygene.util.attribute.AttributeManager; 8 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.AbstractSimpleBuilding; 9 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 10 | import fr.ign.mpp.configuration.GraphConfiguration; 11 | import fr.ign.mpp.configuration.GraphVertex; 12 | 13 | public class ExportAsFeatureCollection { 14 | GraphConfiguration config; 15 | int id = -1; 16 | long seed = -1; 17 | boolean exportId = false; 18 | boolean exportSeed = false; 19 | 20 | public ExportAsFeatureCollection(GraphConfiguration cc) { 21 | this.config = cc; 22 | } 23 | 24 | public ExportAsFeatureCollection(GraphConfiguration cc, int id) { 25 | this.config = cc; 26 | this.id = id; 27 | this.exportId = true; 28 | } 29 | 30 | public ExportAsFeatureCollection(GraphConfiguration cc, int id, long seed) { 31 | this.config = cc; 32 | this.id = id; 33 | this.seed = seed; 34 | this.exportId = this.exportSeed = true; 35 | } 36 | 37 | public IFeatureCollection getFeatureCollection() { 38 | IFeatureCollection featC = new FT_FeatureCollection<>(); 39 | for (GraphVertex v : this.config.getGraph().vertexSet()) { 40 | 41 | AbstractSimpleBuilding build = v.getValue(); 42 | 43 | IFeature feat = new DefaultFeature(build.generated3DGeom()); 44 | if (this.exportId) { 45 | AttributeManager.addAttribute(feat, "idparc", this.id, "Integer"); 46 | } 47 | 48 | if (build instanceof Cuboid) { 49 | Cuboid c = (Cuboid) build; 50 | 51 | AttributeManager.addAttribute(feat, "centerX", c.getCenterx(), "Double"); 52 | AttributeManager.addAttribute(feat, "centerY", c.getCentery(), "Double"); 53 | AttributeManager.addAttribute(feat, "width", c.getWidth(), "Double"); 54 | AttributeManager.addAttribute(feat, "lenght", c.getLength(), "Double"); 55 | AttributeManager.addAttribute(feat, "height", c.getHeight(), "Double"); 56 | AttributeManager.addAttribute(feat, "orient", c.getOrientation(), "Double"); 57 | 58 | } 59 | 60 | if (this.exportSeed) { 61 | AttributeManager.addAttribute(feat, "seed", this.seed, "Long"); 62 | } 63 | featC.add(feat); 64 | } 65 | return featC; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/fr/ign/cogit/simplu3d/util/convert/TransformXMLToJSON.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.util.convert; 2 | 3 | import java.io.File; 4 | import java.io.FileWriter; 5 | import java.io.IOException; 6 | 7 | import org.json.simple.JSONObject; 8 | 9 | import fr.ign.parameters.Parameter; 10 | import fr.ign.parameters.ParameterComponent; 11 | import fr.ign.parameters.Parameters; 12 | 13 | public class TransformXMLToJSON { 14 | public static void main(String[] args) throws Exception { 15 | String folderName = TransformXMLToJSON.class.getClassLoader().getResource("scenario/").getPath(); 16 | File folderOut = new File("JSON"); 17 | final boolean mkdirs = folderOut.mkdirs(); 18 | File folder = new File(folderName); 19 | File[] files = folder.listFiles(); 20 | for (File fileIn: files) { 21 | System.out.println(fileIn); 22 | if (fileIn.getName().endsWith(".xml")) { 23 | Parameters p = Parameters.unmarshall(fileIn); 24 | JSONObject obj = new JSONObject(); 25 | for (ParameterComponent c : p.entry) { 26 | Parameter param = (Parameter) c; 27 | obj.put(param.getKey(), param.getValue()); 28 | } 29 | try (FileWriter file = new FileWriter(new File(folderOut, fileIn.getName().replaceAll(".xml", ".json")))) { 30 | file.write(obj.toJSONString()); 31 | file.flush(); 32 | 33 | } catch (IOException e) { 34 | e.printStackTrace(); 35 | } 36 | System.out.print(obj); 37 | } 38 | } 39 | //String fileName = "scenariotest.xml"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/DOC_URBA.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/DOC_URBA.dbf -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/DOC_URBA.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/DOC_URBA.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/DOC_URBA.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/DOC_URBA.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/MNT_BD3D.asc.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 135.18735 6 | 160.51265 7 | 1000 8 | 0 9 | 0 10 | 4|0|0|0|1|0|0|0|8|0|0|0|11|0|0|0|6|0|0|0|7|0|0|0|8|0|0|0|5|0|0|0|7|0|0|0|9|0|0|10|0|0|0|31|0|0|0|57|0|0|0|64|0|0|0|80|0|0|0|89|0|0|0|113|0|0|0|130|0|0|0|136|0|0|0|186|0|0|0|231|0|0|0|240|0|0|0|264|0|0|0|376|0|0|0|569|0|0|0|622|0|0|0|774|0|0|0|1045|0|0|0|1479|0|0|0|1927|0|0|3112|0|0|0|3650|0|0|0|3341|0|0|0|3454|0|0|0|3826|0|0|0|4349|0|0|0|5034|0|0|0|5529|0|0|0|6142|0|0|0|5636|0|0|0|5534|0|0|0|5185|0|0|0|5001|0|0|0|4822|0|0|0|5033|0|0|0|4718|0|0|0|4198|0|0|0|3628|0|0|0|3216|0|0|2726|0|0|0|2275|0|0|0|1878|0|0|0|1554|0|0|0|1296|0|0|0|1033|0|0|0|954|0|0|0|719|0|0|0|584|0|0|0|479|0|0|0|404|0|0|0|320|0|0|0|294|0|0|0|301|0|0|0|296|0|0|0|224|0|0|0|216|0|0|0|225|0|0|0|195|0|0|0|161|0|0|156|0|0|0|146|0|0|0|120|0|0|0|100|0|0|0|112|0|0|0|97|0|0|0|88|0|0|0|80|0|0|0|78|0|0|0|70|0|0|0|66|0|0|0|68|0|0|0|56|0|0|0|46|0|0|0|56|0|0|0|38|0|0|0|47|0|0|0|39|0|0|0|38|0|0|33|0|0|0|39|0|0|0|38|0|0|0|27|0|0|0|23|0|0|0|39|0|0|0|24|0|0|0|25|0|0|0|15|0|0|0|22|0|0|0|20|0|0|0|17|0|0|0|15|0|0|0|20|0|0|0|12|0|0|0|14|0|0|0|11|0|0|0|15|0|0|0|18|0|0|0|12|0|0|7|0|0|0|4|0|0|0|6|0|0|0|13|0|0|0|2|0|0|0|5|0|0|0|7|0|0|0|5|0|0|0|4|0|0|0|5|0|0|0|2|0|0|0|3|0|0|0|5|0|0|0|1|0|0|0|2|0|0|0|2|0|0|0|2|0|0|0|5|0|0|0|3|0|0|1|0|0|0|2|0|0|0|2|0|0|0|2|0|0|0|3|0|0|0|3|0|0|0|4|0|0|0|2|0|0|0|1|0|0|0|2|0|0|0|2|0|0|0|1|0|0|0|0|0|0|0|1|0|0|0|3|0|0|0|0|0|0|0|2|0|0|0|0|0|0|0|1|0|0|0|0|0|0|1|0|0|0|1|0|0|0|1|0|0|0|2|0|0|0|2|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|2|0|0|0|0|0|0|0|1|0|0|0|2|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|1|0|0|0|1|0|0|0|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|2|0|0|0|0|0|0|0|0|0|0|0|1|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|2|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1 11 | 12 | 13 | 14 | 160.5 15 | 139.30945831438 16 | 135.2 17 | 1.0382970681875 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/PRESCRIPTION_LIN.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/PRESCRIPTION_LIN.dbf -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/PRESCRIPTION_LIN.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/PRESCRIPTION_LIN.qpj: -------------------------------------------------------------------------------- 1 | GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] 2 | -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/PRESCRIPTION_LIN.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/PRESCRIPTION_LIN.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/PRESCRIPTION_LIN.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/PRESCRIPTION_LIN.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/ZONE_URBA.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/ZONE_URBA.dbf -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/ZONE_URBA.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/ZONE_URBA.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/ZONE_URBA.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/ZONE_URBA.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/background3D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/background3D.png -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/bati.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/bati.dbf -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/bati.prj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/bati.prj -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/bati.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/bati.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/bati.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/bati.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/parcelle.dbf: -------------------------------------------------------------------------------- 1 | _A 2 | WID_ParcellN 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/parcelle.prj: -------------------------------------------------------------------------------- 1 | PROJCS["Lambert_Conformal_Conic",GEOGCS["GCS_GRS 1980(IUGG, 1980)",DATUM["D_unknown",SPHEROID["GRS80",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["standard_parallel_1",44],PARAMETER["standard_parallel_2",49],PARAMETER["latitude_of_origin",46.5],PARAMETER["central_meridian",3],PARAMETER["false_easting",700000],PARAMETER["false_northing",6600000],UNIT["Meter",1],PARAMETER["scale_factor",1.0]] -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/parcelle.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/parcelle.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/parcelle.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/parcelle.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/parcelleIgloo.dbf: -------------------------------------------------------------------------------- 1 | wA 2 | WID_ParcellN 55 -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/parcelleIgloo.prj: -------------------------------------------------------------------------------- 1 | PROJCS["Lambert_Conformal_Conic",GEOGCS["GCS_GRS 1980(IUGG, 1980)",DATUM["D_unknown",SPHEROID["GRS80",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["standard_parallel_1",44],PARAMETER["standard_parallel_2",49],PARAMETER["latitude_of_origin",46.5],PARAMETER["central_meridian",3],PARAMETER["false_easting",700000],PARAMETER["false_northing",6600000],UNIT["Meter",1],PARAMETER["scale_factor",1.0]] -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/parcelleIgloo.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/parcelleIgloo.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/parcelleIgloo.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/parcelleIgloo.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/route.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/route.dbf -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/route.prj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/route.prj -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/route.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/route.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data/route.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data/route.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/Coord.txt: -------------------------------------------------------------------------------- 1 | xmin = 1052353.72956 2 | xmax = 1052592.48956 3 | ymin = 6841006.49397 4 | ymax = 6840777.25897 -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/Merged.asc.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 128.9665 6 | 196.0335 7 | 1000 8 | 0 9 | 0 10 | 133|0|0|0|0|0|0|0|0|0|0|0|0|0|0|193|0|0|0|0|0|0|0|0|0|0|0|0|0|0|136|0|0|0|0|0|0|0|0|0|0|0|0|0|0|763|0|0|0|0|0|0|0|0|0|0|0|0|0|0|2952|0|0|0|0|0|0|0|0|0|0|0|0|0|0|4556|0|0|0|0|0|0|0|0|0|0|0|0|0|2661|0|0|0|0|0|0|0|0|0|0|0|0|0|0|2755|0|0|0|0|0|0|0|0|0|0|0|0|0|0|2068|0|0|0|0|0|0|0|0|0|0|0|0|0|0|3503|0|0|0|0|0|0|0|0|0|0|0|0|0|0|7091|0|0|0|0|0|0|0|0|0|0|0|0|0|0|9560|0|0|0|0|0|0|0|0|0|0|0|0|0|0|6434|0|0|0|0|0|0|0|0|0|0|0|0|0|0|7726|0|0|0|0|0|0|0|0|0|0|0|0|0|0|7072|0|0|0|0|0|0|0|0|0|0|0|0|0|0|6357|0|0|0|0|0|0|0|0|0|0|0|0|0|0|7335|0|0|0|0|0|0|0|0|0|0|0|0|0|5453|0|0|0|0|0|0|0|0|0|0|0|0|0|0|4340|0|0|0|0|0|0|0|0|0|0|0|0|0|0|5511|0|0|0|0|0|0|0|0|0|0|0|0|0|0|5620|0|0|0|0|0|0|0|0|0|0|0|0|0|0|3993|0|0|0|0|0|0|0|0|0|0|0|0|0|0|3724|0|0|0|0|0|0|0|0|0|0|0|0|0|0|2046|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1742|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1256|0|0|0|0|0|0|0|0|0|0|0|0|0|0|756|0|0|0|0|0|0|0|0|0|0|0|0|0|0|531|0|0|0|0|0|0|0|0|0|0|0|0|0|583|0|0|0|0|0|0|0|0|0|0|0|0|0|0|612|0|0|0|0|0|0|0|0|0|0|0|0|0|0|609|0|0|0|0|0|0|0|0|0|0|0|0|0|0|407|0|0|0|0|0|0|0|0|0|0|0|0|0|0|428|0|0|0|0|0|0|0|0|0|0|0|0|0|0|430|0|0|0|0|0|0|0|0|0|0|0|0|0|0|439|0|0|0|0|0|0|0|0|0|0|0|0|0|0|465|0|0|0|0|0|0|0|0|0|0|0|0|0|0|450|0|0|0|0|0|0|0|0|0|0|0|0|0|0|418|0|0|0|0|0|0|0|0|0|0|0|0|0|0|491|0|0|0|0|0|0|0|0|0|0|0|0|0|0|482|0|0|0|0|0|0|0|0|0|0|0|0|0|546|0|0|0|0|0|0|0|0|0|0|0|0|0|0|608|0|0|0|0|0|0|0|0|0|0|0|0|0|0|732|0|0|0|0|0|0|0|0|0|0|0|0|0|0|831|0|0|0|0|0|0|0|0|0|0|0|0|0|0|817|0|0|0|0|0|0|0|0|0|0|0|0|0|0|930|0|0|0|0|0|0|0|0|0|0|0|0|0|0|725|0|0|0|0|0|0|0|0|0|0|0|0|0|0|773|0|0|0|0|0|0|0|0|0|0|0|0|0|0|478|0|0|0|0|0|0|0|0|0|0|0|0|0|0|445|0|0|0|0|0|0|0|0|0|0|0|0|0|0|250|0|0|0|0|0|0|0|0|0|0|0|0|0|302|0|0|0|0|0|0|0|0|0|0|0|0|0|0|307|0|0|0|0|0|0|0|0|0|0|0|0|0|0|295|0|0|0|0|0|0|0|0|0|0|0|0|0|0|181|0|0|0|0|0|0|0|0|0|0|0|0|0|0|162|0|0|0|0|0|0|0|0|0|0|0|0|0|0|115|0|0|0|0|0|0|0|0|0|0|0|0|0|0|99|0|0|0|0|0|0|0|0|0|0|0|0|0|0|83|0|0|0|0|0|0|0|0|0|0|0|0|0|0|44|0|0|0|0|0|0|0|0|0|0|0|0|0|0|34|0|0|0|0|0|0|0|0|0|0|0|0|0|0|37|0|0|0|0|0|0|0|0|0|0|0|0|0|28|0|0|0|0|0|0|0|0|0|0|0|0|0|0|15|0|0|0|0|0|0|0|0|0|0|0|0|0|0|12|0|0|0|0|0|0|0|0|0|0|0|0|0|0|12|0|0|0|0|0|0|0|0|0|0|0|0|0|0|7|0|0|0|0|0|0|0|0|0|0|0|0|0|0|4 11 | 12 | 13 | 14 | 196 15 | 146.35920564186 16 | 129 17 | 10.59628260448 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/MergedSmall.asc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/MergedSmall.asc -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/MergedSmall.asc.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 137.975 6 | 139.025 7 | 20 8 | 0 9 | 0 10 | 18|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|2 11 | 12 | 13 | 14 | 139 15 | 138.1 16 | 138 17 | 0.30000000000631 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/background3D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/background3D.png -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/background3D.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/background3D.tiff -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/bati.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/bati.dbf -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/bati.prj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/bati.prj -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/bati.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/bati.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/bati.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/bati.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/decoup.dbf: -------------------------------------------------------------------------------- 1 | _A WidN 2 | 0 -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/decoup.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/decoup.qpj: -------------------------------------------------------------------------------- 1 | GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] 2 | -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/decoup.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/decoup.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/decoup.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/decoup.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/env3D: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/env3D -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/mergedout.asc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/mergedout.asc -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/mergedout.asc.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 137.9880952380952 6 | 139.0119047619048 7 | 42 8 | 0 9 | 0 10 | 36|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|6 11 | 12 | 13 | 14 | 139 15 | 138.14285714286 16 | 138 17 | 0.34992710611379 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/parcelle.dbf: -------------------------------------------------------------------------------- 1 |  2 | ! -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/parcelle.prj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/parcelle.prj -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/parcelle.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/parcelle.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/parcelle.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/parcelle.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/route.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/route.dbf -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/route.prj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/route.prj -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/route.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/route.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/route.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/route.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/shapeModif.dbf: -------------------------------------------------------------------------------- 1 | s+a idN TypeC 0M 0M 0T 0T 0T 0M 0M 0M 0M 0M 0M 0T 0T 0T 0T 0T 0M 0M 0T 0T 0T 0M 0M 0M 0M 0T 0M 0M 0T 0T 0T 0T 0T 0M 0M 0M 0M 0M 0M 0M 0M 0M 0M -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/shapeModif.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/shapeModif.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/shapeModif.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/shapeModif.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/zonage.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/zonage.dbf -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/zonage.prj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/zonage.prj -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/zonage.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/zonage.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/data2/zonage.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/data2/zonage.shx -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/simul/simul.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/simul/simul.dbf -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/simul/simul.prj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/simul/simul.prj -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/simul/simul.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/simul/simul.shp -------------------------------------------------------------------------------- /src/main/resources/fr/ign/cogit/simplu3d/simul/simul.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/main/resources/fr/ign/cogit/simplu3d/simul/simul.shx -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Root logging level is info, and we're using two logging targets 2 | log4j.rootLogger=INFO, fichier, console 3 | 4 | log4j.appender.console=org.apache.log4j.ConsoleAppender 5 | log4j.appender.console.layout.ConversionPattern=%d{ABSOLUTE} %5p (%F:%M:%L) - %m%n 6 | log4j.appender.console.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.console.Threshold=FATAL 8 | 9 | log4j.appender.fichier=org.apache.log4j.RollingFileAppender 10 | log4j.appender.fichier.File=log4j.log 11 | log4j.appender.fichier.layout=org.apache.log4j.PatternLayout 12 | log4j.appender.fichier.layout.ConversionPattern=%d{ABSOLUTE} %5p (%F:%M:%L) - %m%n 13 | log4j.appender.fichier.MaxFileSize=50MB 14 | # Keep ten backup files 15 | log4j.appender.fichier.MaxBackupIndex=10 16 | log4j.appender.fichier.Append=false 17 | log4j.appender.fichier.Threshold=DEBUG 18 | 19 | log4j.logger.fr.ign.cogit.geoxygene.spatial.coordgeom.GM_Envelope=INFO 20 | log4j.logger.tudresden.ocl20.pivot=ERROR 21 | log4j.logger.fr.ign.cogit.simplu3d.solver=ERROR 22 | log4j.logger.fr.ign.cogit.simplu3d.test.rjmcmc=ERROR 23 | -------------------------------------------------------------------------------- /src/main/resources/scenario/building_parameters_project_expthese_3.json: -------------------------------------------------------------------------------- 1 | {"amplitudeRotate":"180","delta":"5","amplitudeMove":"2","amplitudeHeight":"2","filmvisitorb":"180","maxheight":"12","yminbg":"6840539.08","filmvisitorg":"180","amplitudeMaxDim":"2","visitorviewer":"false","csvvisitorend":"false","energy":"12","showbackground":"true","csvfilename":"export.csv","shapefilewriter":"false","end_test_type":"relative","filmvisitor":"false","filmvisitorvecty":"-20","filmvisitorvectx":"-15","poisson":"20","background_img":"background3D.png","config_shape_file":"","folder":"","ponderation_difference_ext":"0","filmvisitorvectz":"15","minwid":"5","maxlen":"30","ponderation_volume_inter":"1","xmaxbg":"1051264.80","ponderation_volume":"1","csvfilenamend":"exportEndStats.csv","pdeath":"0.5","result":"\/tmp\/","statsvisitor":"false","relative_nb_iter":"100000","minheight":"3","filmvisitorr":"180","maxwid":"30","nbdump":"5000","temp":"13500","outputstreamvisitor":"false","deccoef":"0.99999","filmvisitorx":"1051180.7261527262","filmvisitory":"6840750.337137596","xminbg":"1051042.85","csvvisitor":"false","absolute_nb_iter":"2000000","load_existing_config":"0","minlen":"5","ymaxbg":"6840679.27","filmvisitorz":"160","pbirth":"0.2","z":"138","nbsave":"10000"} -------------------------------------------------------------------------------- /src/main/resources/scenario/parameters_iauidf.json: -------------------------------------------------------------------------------- 1 | {"amplitudeRotate":"180","delta":"5","amplitudeMove":"2","amplitudeHeight":"2","filmvisitorb":"180","maxheight":"25","yminbg":"6840539.08","filmvisitorg":"180","amplitudeMaxDim":"2","visitorviewer":"false","csvvisitorend":"false","energy":"1","showbackground":"true","csvfilename":"export.csv","shapefilewriter":"false","end_test_type":"relative","filmvisitor":"false","filmvisitorvecty":"-20","filmvisitorvectx":"-15","poisson":"20","background_img":"background3D.png","config_shape_file":"","folder":"","filmvisitorvectz":"15","minwid":"4","maxlen":"100","ponderation_volume_inter":"1","xmaxbg":"1051264.80","ponderation_volume":"1","csvfilenamend":"exportEndStats.csv","result":"\/home\/adminlocal\/tmp\/","statsvisitor":"false","relative_nb_iter":"50000","minheight":"0.5","filmvisitorr":"180","maxwid":"15","nbdump":"10000","temp":"180000","outputstreamvisitor":"true","deccoef":"0.99999","filmvisitorx":"1051180.7261527262","filmvisitory":"6840750.337137596","xminbg":"1051042.85","csvvisitor":"false","absolute_nb_iter":"2000000","load_existing_config":"0","minlen":"5","ymaxbg":"6840679.27","filmvisitorz":"160","pbirth":"1.0","z":"138","pbirthdeath":"0.2","nbsave":"5000000"} -------------------------------------------------------------------------------- /src/main/resources/scenario/parameters_iauidf_test.json: -------------------------------------------------------------------------------- 1 | {"amplitudeRotate":"180","delta":"5","amplitudeMove":"2","amplitudeHeight":"2","filmvisitorb":"180","maxheight":"25","yminbg":"6840539.08","filmvisitorg":"180","amplitudeMaxDim":"2","visitorviewer":"true","csvvisitorend":"false","energy":"1","showbackground":"true","csvfilename":"export.csv","shapefilewriter":"false","end_test_type":"relative","filmvisitor":"false","filmvisitorvecty":"-20","filmvisitorvectx":"-15","poisson":"20","background_img":"background3D.png","config_shape_file":"","folder":"","filmvisitorvectz":"15","minwid":"4","maxlen":"100","ponderation_volume_inter":"1","xmaxbg":"1051264.80","ponderation_volume":"1","csvfilenamend":"exportEndStats.csv","result":"\/home\/adminlocal\/tmp\/","statsvisitor":"true","relative_nb_iter":"1500000","minheight":"0.5","filmvisitorr":"180","maxwid":"15","nbdump":"10000","temp":"180000","outputstreamvisitor":"true","deccoef":"0.99999","filmvisitorx":"1051180.7261527262","filmvisitory":"6840750.337137596","xminbg":"1051042.85","csvvisitor":"false","absolute_nb_iter":"2000000","load_existing_config":"0","minlen":"5","ymaxbg":"6840679.27","filmvisitorz":"160","pbirth":"1.0","z":"138","pbirthdeath":"0.2","nbsave":"50000"} -------------------------------------------------------------------------------- /src/main/resources/scenario/paramsIgloo.json: -------------------------------------------------------------------------------- 1 | { 2 | "energy":"12", 3 | "ponderation_volume":"1", 4 | "ponderation_volume_inter":"2", 5 | "ponderation_difference_ext":"5", 6 | "ponderation_compacity":"2", 7 | 8 | 9 | "maxwid":"15", 10 | "minwid":"5", 11 | "minlen":"5", 12 | "maxlen":"30", 13 | "minheight":"3", 14 | "maxheight":"25", 15 | 16 | "amplitudeMove":"2", 17 | "amplitudeMaxDim":"2", 18 | "amplitudeHeight":"2", 19 | "amplitudeRotate":"180", 20 | 21 | "temp":"13500", 22 | "deccoef":"0.99999", 23 | "poisson":"20", 24 | "pbirth":"0.5", 25 | "pdeath":"0.5", 26 | 27 | "end_test_type":"absolute", 28 | "delta":"5", 29 | "relative_nb_iter":"100000", 30 | "absolute_nb_iter":"1500000", 31 | 32 | "result":"\/tmp\/", 33 | 34 | 35 | "load_existing_config":"0", 36 | "config_shape_file":"", 37 | 38 | "nbdump":"5000", 39 | "nbsave":"10000", 40 | 41 | "outputstreamvisitor":"true", 42 | 43 | "statsvisitor":"true", 44 | 45 | "csvvisitor":"false", 46 | "csvfilename":"export.csv", 47 | "csvvisitorend":"false", 48 | "csvfilenamend":"exportEndStats.csv", 49 | 50 | 51 | "shapefilewriter":"false", 52 | "folder":"", 53 | 54 | 55 | "visitorviewer":"false", 56 | "showbackground":"true", 57 | "background_img":"/home/paulchapron/dev/simplu3d/src/main/resources/fr/ign/cogit/simplu3d/data/background3D.png", 58 | "z":"0", 59 | "xminbg":"1051042.85", 60 | "yminbg":"6840539.08", 61 | "xmaxbg":"1051264.80", 62 | "ymaxbg":"6840679.27", 63 | 64 | "filmvisitor":"false", 65 | "filmvisitorvecty":"-15", 66 | "filmvisitorvectx":"-15", 67 | "filmvisitorvectz":"5", 68 | 69 | 70 | "filmvisitorx":"1051042.85", 71 | "filmvisitory":"6840539.08", 72 | "filmvisitorz":"45", 73 | 74 | "filmvisitorr":"180", 75 | "filmvisitorg":"180", 76 | "filmvisitorb":"180" 77 | } -------------------------------------------------------------------------------- /src/main/resources/scenario/scenariotest.json: -------------------------------------------------------------------------------- 1 | {"amplitudeRotate":"180","delta":"5","amplitudeMove":"2","mindim":"1","amplitudeHeight":"2","filmvisitorb":"180","maxheight":"12","yminbg":"6840539.08","filmvisitorg":"180","amplitudeMaxDim":"2","visitorviewer":"false","csvvisitorend":"false","energy":"5","showbackground":"true","csvfilename":"export.csv","shapefilewriter":"false","end_test_type":"composite","filmvisitor":"false","filmvisitorvecty":"-20","filmvisitorvectx":"-15","poisson":"20","background_img":"background3D.png","maxdim":"30","config_shape_file":"C:\/Users\/mbrasebin\/Desktop\/Exp1\/test1\/Montage\/Test\/result_1975488 .shp","folder":"E:\/mbrasebin\/Donnees\/Strasbourg\/GTRU\/ProjectT3\/","ponderation_difference_ext":"5","filmvisitorvectz":"15","ponderation_volume_inter":"1","xmaxbg":"1051264.80","ponderation_volume":"1","csvfilenamend":"exportEndStats.csv","pdeath":"0.5","result":"E:\/temp2\/","statsvisitor":"false","relative_nb_iter":"50000","minheight":"2","filmvisitorr":"180","nbdump":"5000","temp":"10800","outputstreamvisitor":"false","deccoef":"0.99999","filmvisitorx":"1051180.7261527262","filmvisitory":"6840750.337137596","xminbg":"1051042.85","csvvisitor":"false","absolute_nb_iter":"2000000","load_existing_config":"0","ymaxbg":"6840679.27","filmvisitorz":"160","pbirth":"0.2","z":"138","nbsave":"50000"} -------------------------------------------------------------------------------- /src/main/resources/scenario/tableParameter.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE parameters 2 | ( 3 | energy double precision, 4 | ponderation_volume double precision, 5 | ponderation_difference_ext double precision, 6 | ponderation_volume_inter double precision, 7 | mindim double precision, 8 | maxdim double precision, 9 | minheight double precision, 10 | maxheight double precision, 11 | pbirth double precision, 12 | pdeath double precision, 13 | "amplitudeMaxDim" double precision, 14 | "amplitudeHeight" double precision, 15 | "amplitudeMove" double precision, 16 | "amplitudeRotate" double precision, 17 | temp double precision, 18 | deccoef double precision, 19 | "isAbsoluteNumber" boolean, 20 | nbiter integer, 21 | delta double precision, 22 | poisson double precision, 23 | id serial NOT NULL, 24 | CONSTRAINT prim_param PRIMARY KEY (id) 25 | ) 26 | WITH ( 27 | OIDS=FALSE 28 | ); 29 | -------------------------------------------------------------------------------- /src/test/java/fr/ign/cogit/simplu3d/test/rjmcmc/cuboid/transformation/RotateCuboid2Test.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.test.rjmcmc.cuboid.transformation; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | 6 | import com.vividsolutions.jts.util.Assert; 7 | 8 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 9 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.transformation.RotateCuboid; 10 | 11 | /** 12 | * 13 | * This software is released under the licence CeCILL 14 | * 15 | * see LICENSE.TXT 16 | * 17 | * see http://www.cecill.info/ 18 | * 19 | * 20 | * 21 | * copyright IGN 22 | * 23 | * @author Brasebin Mickaël 24 | * 25 | * @version 1.0 26 | **/ 27 | public class RotateCuboid2Test { 28 | RotateCuboid t; 29 | 30 | @Before 31 | public void setUp() throws Exception { 32 | t = new RotateCuboid(5 * Math.PI / 180); 33 | } 34 | 35 | @Test 36 | public void testApply() { 37 | int dimension = t.dimension() - 1; 38 | // double[] in = new double[] { 0, 0, 5, 1, 20, 0, 1 }; 39 | double[] in = new double[] { 0.0, 5.0, 1.0, 20.0, 0.0, 0.0, 1.0 }; 40 | double[] out = new double[7]; 41 | t.apply(true, in, out); 42 | String outString = ""; 43 | for (int i = 0; i < dimension; i++) { 44 | outString += out[i] + " "; 45 | } 46 | outString += out[dimension]; 47 | System.out.println("out = " + outString); 48 | Cuboid cuboidIn = new Cuboid(in[0], in[1], 49 | in[2], in[3], in[4], in[5]); 50 | Cuboid cuboidOut = new Cuboid(out[0], out[1], 51 | out[2], out[3], out[4], out[5]); 52 | System.out.println("In = " + cuboidIn.toGeometry()); 53 | System.out.println("Out = " + cuboidOut.toGeometry()); 54 | // Assert.equals(cuboidIn.toGeometry().toString(), cuboidOut.toGeometry() 55 | // .toString()); 56 | } 57 | 58 | @Test 59 | public void testInverse() { 60 | 61 | int dimension = t.dimension() - 1; 62 | // double[] in = new double[] { 0, 0, 5, 1, 20, 0, 1 }; 63 | double[] lvalIn = new double[] { 0.0, 5.0, 1.0, 20.0, 0.0, 0.0, 1.0 }; 64 | 65 | // double[] out = new double[dimension]; 66 | double[] lvalOut = new double[7]; 67 | t.apply(true, lvalIn, lvalOut); 68 | 69 | double[] lvalOutInv = new double[7]; 70 | 71 | t.apply(false, lvalOut, lvalOutInv); 72 | 73 | String inString = ""; 74 | for (int i = 0; i < dimension; i++) { 75 | inString += lvalIn[i] + " "; 76 | } 77 | inString += lvalIn[dimension]; 78 | 79 | System.out.println("in = " + inString); 80 | 81 | String outString = ""; 82 | for (int i = 0; i < dimension; i++) { 83 | outString += lvalOutInv[i] + " "; 84 | } 85 | outString += lvalOutInv[dimension]; 86 | 87 | System.out.println("outInv = " + outString); 88 | Cuboid cuboidOutInv = new Cuboid(lvalOutInv[0], lvalOutInv[1], 89 | lvalOutInv[2], lvalOutInv[3], lvalOutInv[4], 90 | lvalOutInv[5]); 91 | System.out.println("Inv = " + cuboidOutInv.toGeometry()); 92 | Cuboid cuboidIn = new Cuboid(lvalIn[0], lvalIn[1], 93 | lvalIn[2], lvalIn[3], lvalIn[4], lvalIn[5]); 94 | Assert.equals(cuboidOutInv.toGeometry().toString(), cuboidIn 95 | .toGeometry().toString()); 96 | } 97 | 98 | @Test 99 | public void testDimension() { 100 | int dimension = t.dimension(); 101 | Assert.equals(7, dimension); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/test/java/fr/ign/cogit/simplu3d/test/rjmcmc/cuboid/transformation/birth/InversionBirth.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.test.rjmcmc.cuboid.transformation.birth; 2 | 3 | import java.util.List; 4 | 5 | import fr.ign.cogit.geoxygene.api.feature.IFeature; 6 | import fr.ign.cogit.geoxygene.api.feature.IFeatureCollection; 7 | import fr.ign.cogit.geoxygene.api.spatial.coordgeom.IDirectPosition; 8 | import fr.ign.cogit.geoxygene.api.spatial.coordgeom.IPolygon; 9 | import fr.ign.cogit.geoxygene.api.spatial.geomaggr.IMultiSurface; 10 | import fr.ign.cogit.geoxygene.api.spatial.geomprim.IOrientableSurface; 11 | import fr.ign.cogit.geoxygene.contrib.cartetopo.Face; 12 | import fr.ign.cogit.geoxygene.contrib.delaunay.TriangulationJTS; 13 | import fr.ign.cogit.geoxygene.convert.FromGeomToSurface; 14 | import fr.ign.cogit.geoxygene.feature.DefaultFeature; 15 | import fr.ign.cogit.geoxygene.feature.FT_FeatureCollection; 16 | import fr.ign.cogit.geoxygene.sig3d.distribution.EquiSurfaceDistribution; 17 | import fr.ign.cogit.geoxygene.sig3d.topology.TriangulationLoader; 18 | import fr.ign.cogit.geoxygene.spatial.geomaggr.GM_MultiSurface; 19 | import fr.ign.cogit.geoxygene.spatial.geomprim.GM_Point; 20 | import fr.ign.cogit.geoxygene.util.conversion.ShapefileReader; 21 | import fr.ign.cogit.geoxygene.util.conversion.ShapefileWriter; 22 | /** 23 | * 24 | * This software is released under the licence CeCILL 25 | * 26 | * see LICENSE.TXT 27 | * 28 | * see http://www.cecill.info/ 29 | * 30 | * 31 | * 32 | * copyright IGN 33 | * 34 | * @author Brasebin Mickaël 35 | * 36 | * @version 1.0 37 | **/ 38 | public class InversionBirth { 39 | 40 | /** 41 | * Class to test if the birth operation is reversible 42 | * @param args ont used 43 | * @throws Exception exception in sampler instanciation 44 | */ 45 | public static void main(String[] args) throws Exception { 46 | 47 | int nbSample = 10000; 48 | 49 | String folder = "E:/mbrasebin/Donnees/Strasbourg/DistribTest/"; 50 | 51 | String file = folder + "parcelle.shp"; 52 | String fileOut = folder + "out.shp"; 53 | 54 | IFeatureCollection feat = ShapefileReader.read(file); 55 | 56 | if (feat == null || feat.isEmpty()) return; 57 | List lOS = FromGeomToSurface.convertGeom(feat.get(1) 58 | .getGeom()); 59 | 60 | TriangulationJTS triangulation = TriangulationLoader 61 | .generate((IPolygon) lOS.get(0)); 62 | 63 | triangulation.triangule(); 64 | 65 | IMultiSurface iMS = new GM_MultiSurface<>(); 66 | 67 | for (Face f : triangulation.getPopFaces()) { 68 | 69 | if (lOS.get(0).contains(f.getGeom())) { 70 | iMS.add(f.getGeometrie()); 71 | 72 | // break; 73 | } 74 | 75 | } 76 | 77 | EquiSurfaceDistribution eq = new EquiSurfaceDistribution(iMS); 78 | 79 | IFeatureCollection featCollOut = new FT_FeatureCollection<>(); 80 | 81 | for (int i = 0; i < nbSample; i++) { 82 | 83 | double rand1 = Math.random(); 84 | double rand2 = Math.random(); 85 | 86 | IDirectPosition dpCal = eq.sample(rand1, rand2); 87 | 88 | featCollOut.add(new DefaultFeature(new GM_Point(dpCal))); 89 | 90 | 91 | IDirectPosition dpInv = eq.inversample(dpCal.getX(), dpCal.getY()); 92 | 93 | if((Math.abs( dpInv.getX() - eq.getCorrectedRand()) > 0.0001) || (0.0001 < Math.abs(dpInv.getY() - rand2))){ 94 | 95 | 96 | 97 | System.out.println("Error X : " + dpInv.getX() + " " + eq.getCorrectedRand()); 98 | System.out.println("Error Y : " + dpInv.getY() + " " + rand2); 99 | } 100 | 101 | 102 | 103 | } 104 | 105 | System.out.println(featCollOut.size()); 106 | 107 | ShapefileWriter.write(featCollOut, fileOut); 108 | 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/test/java/fr/ign/cogit/simplu3d/test/rjmcmc/cuboid/transformation/birth/SimplePolygonTransformTest.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.test.rjmcmc.cuboid.transformation.birth; 2 | 3 | import org.apache.commons.math3.random.RandomGenerator; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | import org.locationtech.jts.geom.Coordinate; 7 | import org.locationtech.jts.geom.GeometryFactory; 8 | import org.locationtech.jts.geom.MultiPoint; 9 | import org.locationtech.jts.io.WKTReader; 10 | import org.locationtech.jts.io.WKTWriter; 11 | 12 | import fr.ign.cogit.simplu3d.rjmcmc.generic.transform.SimplePolygonTransform; 13 | import fr.ign.random.Random; 14 | 15 | public class SimplePolygonTransformTest { 16 | SimplePolygonTransform t; 17 | 18 | @Before 19 | public void setUp() throws Exception { 20 | String polSTR ="POLYGON ((665218.232277 6856149.105205, 665218.238327 6856149.137445, 665220.677545 6856149.434051, 665218.232277 6856149.105205))"; 21 | WKTReader read = new WKTReader(); 22 | 23 | t = new SimplePolygonTransform(read.read(polSTR)); 24 | } 25 | 26 | @Test 27 | public void testApply() { 28 | 29 | GeometryFactory gf = new GeometryFactory(); 30 | int nbTest = 100; 31 | Coordinate[] tabCoord = new Coordinate[nbTest]; 32 | for (int index = 0; index < nbTest; index++) { 33 | double[] lvalIn = new double[4]; 34 | RandomGenerator generator = Random.random(); 35 | for (int i = 0; i < 2; i++) { 36 | lvalIn[i] = generator.nextDouble(); 37 | } 38 | 39 | 40 | double[] lvalOut = new double[4]; 41 | 42 | t.apply(true, lvalIn, lvalOut); 43 | 44 | tabCoord[index] = new Coordinate(lvalOut[0] , lvalOut[1]); 45 | 46 | } 47 | 48 | 49 | MultiPoint mp = gf.createMultiPoint(tabCoord); 50 | 51 | System.out.println(mp.getCoordinates().length); 52 | 53 | WKTWriter wW = new WKTWriter(); 54 | String wkt = wW.write(mp); 55 | System.out.println(wkt); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/fr/ign/cogit/simplu3d/test/sdpcalc/SDPCalcTest.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.test.sdpcalc; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.junit.Test; 9 | 10 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 11 | import fr.ign.cogit.simplu3d.util.merge.SDPCalc; 12 | 13 | public class SDPCalcTest { 14 | 15 | @Test 16 | public void testOneBuilding() { 17 | Cuboid a = new Cuboid(0, 0, 4, 8, 6, 0); 18 | SDPCalc sd = new SDPCalc(); 19 | List cubes = new ArrayList<>(); 20 | cubes.add(a); 21 | Double d = sd.process(cubes); 22 | assertEquals("sdp must be 4 * 8 * 2 = 64 ", 64.0, d, 0.001); 23 | } 24 | 25 | @Test 26 | public void testListIntersectingBuildings() { 27 | Cuboid a = new Cuboid(0, 0, 4, 8, 6, 0); 28 | Cuboid b = new Cuboid(2, 0, 4, 8, 12, 0); 29 | SDPCalc sd = new SDPCalc(); 30 | List cubes = new ArrayList<>(); 31 | cubes.add(a); 32 | cubes.add(b); 33 | // System.out.println(b.generated3DGeom()); 34 | Double d = sd.process(cubes); 35 | System.out.println(d); 36 | assertEquals("sdp must be 32 + 128 = 160", 160.0, d, 0.001); 37 | } 38 | 39 | @Test 40 | public void testTwoGroupsofBuildings() { 41 | // group 1 sdp = 160 42 | Cuboid a1 = new Cuboid(0, 0, 4, 8, 6, 0); 43 | Cuboid b1 = new Cuboid(2, 0, 4, 8, 12, 0); 44 | 45 | // group 2 sdp = 249 46 | Cuboid a2 = new Cuboid(20, 0, 10, 4, 15, 0); 47 | Cuboid b2 = new Cuboid(18, 0, 6, 6, 10, 0); 48 | Cuboid c2 = new Cuboid(22, -2, 4, 2, 12, 0); 49 | 50 | SDPCalc sd = new SDPCalc(); 51 | List cubes = new ArrayList<>(); 52 | cubes.add(a1); 53 | cubes.add(b1); 54 | cubes.add(a2); 55 | cubes.add(b2); 56 | cubes.add(c2); 57 | 58 | Double d = sd.process(cubes); 59 | System.out.println(d); 60 | assertEquals("sdp must be 32 + 128 = 160 + 249", 160.0 + 249.0, d, 0.001); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/fr/ign/cogit/simplu3d/test/simulator/SimulatorTest.java: -------------------------------------------------------------------------------- 1 | package fr.ign.cogit.simplu3d.test.simulator; 2 | 3 | import java.io.File; 4 | 5 | import org.junit.Test; 6 | 7 | import fr.ign.cogit.simplu3d.demo.DemoEnvironmentProvider; 8 | import fr.ign.cogit.simplu3d.model.BasicPropertyUnit; 9 | import fr.ign.cogit.simplu3d.model.Environnement; 10 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.geometry.impl.Cuboid; 11 | import fr.ign.cogit.simplu3d.rjmcmc.cuboid.optimizer.cuboid.OptimisedBuildingsCuboidFinalDirectRejection; 12 | import fr.ign.cogit.simplu3d.rjmcmc.generic.predicate.SamplePredicate; 13 | import fr.ign.cogit.simplu3d.util.SimpluParameters; 14 | import fr.ign.cogit.simplu3d.util.SimpluParametersJSON; 15 | import fr.ign.mpp.configuration.BirthDeathModification; 16 | import fr.ign.mpp.configuration.GraphConfiguration; 17 | /** 18 | * 19 | * This software is released under the licence CeCILL 20 | * 21 | * see LICENSE.TXT 22 | * 23 | * see http://www.cecill.info/ 24 | * 25 | * 26 | * 27 | * copyright IGN 28 | * 29 | * @author Brasebin Mickaël 30 | * 31 | * @version 1.0 32 | **/ 33 | public class SimulatorTest { 34 | 35 | @Test 36 | public void testImport() throws Exception { 37 | 38 | String folderName = SimulatorTest.class.getClassLoader() 39 | .getResource("scenario/").getPath(); 40 | 41 | String fileName = "scenariotest.json"; 42 | 43 | SimpluParameters p = new SimpluParametersJSON(new File(folderName + fileName)); 44 | 45 | Environnement env = DemoEnvironmentProvider.getDefaultEnvironment(); 46 | 47 | if (env.getBpU().isEmpty()) return; 48 | BasicPropertyUnit bPU = env.getBpU().get(1); 49 | 50 | OptimisedBuildingsCuboidFinalDirectRejection oCB = new OptimisedBuildingsCuboidFinalDirectRejection(); 51 | 52 | // Rules parameters.8 53 | // Distance to road 54 | double distReculVoirie = 2; 55 | // Distance to bottom of the parcel 56 | double distReculFond = 0; 57 | // Distance to lateral parcel limits 58 | double distReculLat = 4; 59 | // Distance between two buildings of a parcel 60 | double distanceInterBati = 0; 61 | // Maximal ratio built area 62 | double maximalCES = 0.5; 63 | 64 | // Instantiation of the rule checker 65 | SamplePredicate, BirthDeathModification> pred = new SamplePredicate<>( 66 | bPU, distReculVoirie, distReculFond, distReculLat, distanceInterBati, maximalCES); 67 | 68 | 69 | oCB.process(bPU, p, env, 1, pred); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-amd64/j3dcore-ogl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-amd64/j3dcore-ogl.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-amd64/tetrahedrize.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-amd64/tetrahedrize.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/j3dcore-d3d.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/j3dcore-d3d.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/j3dcore-ogl-cg.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/j3dcore-ogl-cg.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/j3dcore-ogl-chk.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/j3dcore-ogl-chk.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/j3dcore-ogl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/j3dcore-ogl.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/test/cg.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/test/cg.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/test/cgD3D10.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/test/cgD3D10.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/test/cgD3D8.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/test/cgD3D8.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/test/cgD3D9.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/test/cgD3D9.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/test/cgGL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/test/cgGL.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/test/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/test/glut32.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/tetrahedrize.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/tetrahedrize.dll -------------------------------------------------------------------------------- /src/test/resources/native_libraries/windows-i586/trianguledll.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimPLU3D/simplu3D/ce9ef6e7ddf8a1b9719f46269768fcc6732f2555/src/test/resources/native_libraries/windows-i586/trianguledll.dll -------------------------------------------------------------------------------- /src/test/resources/scenario/scenariotest.json: -------------------------------------------------------------------------------- 1 | {"amplitudeRotate":"180","delta":"5","amplitudeMove":"2","mindim":"1","amplitudeHeight":"2","filmvisitorb":"180","maxheight":"12","yminbg":"6840539.08","filmvisitorg":"180","amplitudeMaxDim":"2","visitorviewer":"false","csvvisitorend":"false","energy":"5","showbackground":"true","csvfilename":"export.csv","shapefilewriter":"false","end_test_type":"composite","filmvisitor":"false","filmvisitorvecty":"-20","filmvisitorvectx":"-15","poisson":"20","background_img":"background3D.png","maxdim":"30","config_shape_file":"C:\/Users\/mbrasebin\/Desktop\/Exp1\/test1\/Montage\/Test\/result_1975488 .shp","folder":"E:\/mbrasebin\/Donnees\/Strasbourg\/GTRU\/ProjectT3\/","ponderation_difference_ext":"5","filmvisitorvectz":"15","ponderation_volume_inter":"1","xmaxbg":"1051264.80","ponderation_volume":"1","csvfilenamend":"exportEndStats.csv","pdeath":"0.5","result":"E:\/temp2\/","statsvisitor":"false","relative_nb_iter":"50000","minheight":"2","filmvisitorr":"180","nbdump":"5000","temp":"10800","outputstreamvisitor":"false","deccoef":"0.99999","filmvisitorx":"1051180.7261527262","filmvisitory":"6840750.337137596","xminbg":"1051042.85","csvvisitor":"false","absolute_nb_iter":"2000000","load_existing_config":"0","ymaxbg":"6840679.27","filmvisitorz":"160","pbirth":"0.2","z":"138","nbsave":"50000"} --------------------------------------------------------------------------------