Merge branch 'origin/2.1.x'
Conflicts:
.gitattributes
xdgnjobs/pom.xml
xdgnjobs/ximple-build/maven/jar-collector/pom.xml
xdgnjobs/ximple-build/maven/jar-collector/src/main/java/com/ximple/eofms/maven/JarCollector.java
xdgnjobs/ximple-build/maven/pom.xml
xdgnjobs/ximple-build/pom.xml
xdgnjobs/ximple-dgnio/pom.xml
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ArcElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ComplexChainElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ComplexElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ComplexShapeElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7Exception.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7OracleReader.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileException.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileHeader.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileReader.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ElementType.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/EllipseElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/FrammeAttributeData.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/GeometryConverter.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/IElementHandler.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/LineElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/LineStringElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Lock.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/NIOUtilities.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ShapeElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/StreamLogging.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TagElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TcbElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TextElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TextNodeElement.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/UserAttributeData.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/util/DgnUtility.java
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/util/PrintfFormat.java
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7OracleReaderTest.java
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7TextElementReaderTest.java
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7fileReaderTest.java
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/OracleTarget.java
xdgnjobs/ximple-elmparser/pom.xml
xdgnjobs/ximple-elmparser/src/main/java/com/ximple/eofms/XElementFetcher.java
xdgnjobs/ximple-elmparser/src/main/java/com/ximple/eofms/XElementParser.java
xdgnjobs/ximple-jobcarrier/pom.xml
xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobCarrier.java
xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobWizard.java
xdgnjobs/ximple-jobcarrier/src/main/resources/com/ximple/eofms/XQuartzJobWizard_zh_TW.properties
xdgnjobs/ximple-jobcarrier/src/main/resources/log4j.properties
xdgnjobs/ximple-jobcarrier/src/main/resources/quartz.properties
xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml
xdgnjobs/ximple-jobcarrier/src/test/java/com/ximple/eofms/XQuartzJobCarrierTest.java
xdgnjobs/ximple-spatialjob/pom.xml
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/collector/FeatureClassification.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/collector/FeatureTypeCollector.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/AbstractDispatchableFilter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/AbstractFLinkageDispatchableFilter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateArcLineStringStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateComplexChainStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateEllipseShapeStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateFeatureTypeEventListener.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateFeatureTypeStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateMultiSymbolStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateSymbolStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateTextStrategy.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/ElementDispatchableFilter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/ElementDispatcher.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/ElementLevelCriterion.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/ElementTypeCriterion.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/FeatureTypeEvent.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeCompIdDispatchableFilter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeCompLevelIdDispatchableFilter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeIdDispatchableFilter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DataReposVersionManager.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DummyFeatureConvertJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2MySQLJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleElementLogger.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleUpgradeBlob2UDTJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleUpgradeJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractDgnToMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractOracleToMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/DummyFeatureConvertMySQlJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/FeatureDgnConvertMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/GeneralDgnConvertMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/IndexDgnConvertMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/OracleConvertMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractDgnToOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractOracleToOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/DummyFeatureConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/FeatureDgnConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/GeneralDgnConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/IndexDgnConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/OracleConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/AbstractDgnToShapefileJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/DummyFeatureConvertShpJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/FeatureDgnConvertShpJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/IndexDgnConvertShpJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/OracleConvertShapefilesJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/Base64.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/BinConverter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/Bits.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ByteArrayCompressor.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/GeomUtil.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/LangUtil.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/PrintfFormat.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/StringUtils.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TPCLIDConverter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TWDDatumConverter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JTSShape.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsBinaryParser.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsBinaryWriter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsGeometry.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsGisWrapper.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsWrapper.java
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/filter/ElementDispatcherRules.xml
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/filter/FeatureClassificationRules.xml
xdgnjobs/ximple-spatialjob/src/main/resources/conf/DefaultConvertShpFilter.xml
xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/filter/ElementDispatcherTest.java
136 files modified
44 files added
| | |
| | | xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileException.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileHeader.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileReader.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Dgn7fileWriter.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ElementFactory.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ElementType.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/EllipseElement.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/FrammeAttributeData.java svneol=native#text/plain |
| | |
| | | xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7OracleReaderTest.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7TextElementReaderTest.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7fileReaderTest.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7fileWriterTest.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/ElementFactoryTest.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/OracleTarget.java svneol=native#text/plain |
| | | xdgnjobs/ximple-dgnio/src/test/resources/com/ximple/io/dgn7/test-data/Demo.dgn -text |
| | | xdgnjobs/ximple-dgnio/src/test/resources/com/ximple/io/dgn7/test-data/HV88491-1.dgn -text |
| | | xdgnjobs/ximple-dgnio/src/test/resources/com/ximple/io/dgn7/test-data/HV88491_0888888.dgn -text |
| | | xdgnjobs/ximple-dgnio/src/test/resources/com/ximple/io/dgn7/test-data/HV88494_0.dgn -text |
| | | xdgnjobs/ximple-dgnio/src/test/resources/com/ximple/io/dgn7/test-data/dgnseed2d.dgn -text |
| | | xdgnjobs/ximple-dgnio/src/test/resources/com/ximple/io/dgn7/test-data/testHV.dgn -text |
| | | xdgnjobs/ximple-elmparser/pom.xml svneol=native#text/xml |
| | | xdgnjobs/ximple-elmparser/src/main/java/com/ximple/eofms/XElementFetcher.java svneol=native#text/plain |
| | |
| | | xdgnjobs/ximple-elmparser/src/main/resources/com/ximple/eofms/XElementParser.properties svneol=native#text/plain |
| | | xdgnjobs/ximple-elmparser/src/main/resources/com/ximple/eofms/XElementParser_zh_TW.properties svneol=native#text/plain |
| | | xdgnjobs/ximple-elmparser/src/main/resources/log4j.properties svneol=native#text/plain |
| | | xdgnjobs/ximple-jobcarrier/log4j.properties -text |
| | | xdgnjobs/ximple-jobcarrier/pom.xml svneol=native#text/xml |
| | | xdgnjobs/ximple-jobcarrier/quartz.properties -text |
| | | xdgnjobs/ximple-jobcarrier/quartz_jobs.xml -text |
| | | xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobCarrier.java svneol=native#text/plain |
| | | xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobWizard.java svneol=native#text/plain |
| | | xdgnjobs/ximple-jobcarrier/src/main/resources/com/ximple/eofms/XQuartzJobWizard.properties svneol=native#text/plain |
| | |
| | | xdgnjobs/ximple-jobcarrier/src/main/resources/log4j.properties svneol=native#text/plain |
| | | xdgnjobs/ximple-jobcarrier/src/main/resources/quartz.properties svneol=native#text/plain |
| | | xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml svneol=native#text/xml |
| | | xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs_edb.xml -text svneol=unset#text/xml |
| | | xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs_shapefiles.xml svneol=native#text/xml |
| | | xdgnjobs/ximple-jobcarrier/src/test/java/com/ximple/eofms/XQuartzJobCarrierTest.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/pom.xml svneol=native#text/xml |
| | |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DataReposVersionManager.java -text |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/DummyFeatureConvertJobContext.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2EdbGeoJob.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2MySQLJob.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java svneol=native#text/plain |
| | |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java -text |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleUpgradeJobContext.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/AbstractDgnToEdbGeoJobContext.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/AbstractOracleToEdbGeoJobContext.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/DummyFeatureConvertEdbGeoJobContext.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/FeatureDgnConvertEdbGeoJobContext.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/GeneralDgnConvertEdbGeoJobContext.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/IndexDgnConvertEdbGeoJobContext.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/OracleConvertEdbGeoJobContext.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractDgnToMySQLJobContext.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractOracleToMySQLJobContext.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/DummyFeatureConvertMySQlJobContext.java svneol=native#text/plain |
| | |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ByteArrayCompressor.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DigesterUtils.java -text |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/EPSG3825GeometryConverterDecorator.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/EPSG3826GeometryConverterDecorator.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FileUtils.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/GeomUtil.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/GeometryConverterDecorator.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/LangUtil.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/PrintfFormat.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/StringUtils.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TPCLIDConverter.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TWD97GeometryConverterDecorator.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TWDDatumConverter.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JTSShape.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsBinaryParser.java svneol=native#text/plain |
| | |
| | | xdgnjobs/ximple-spatialjob/src/main/resources/conf/DefaultConvertShpFilter.xml svneol=native#text/xml |
| | | xdgnjobs/ximple-spatialjob/src/main/resources/conf/DefaultMapGroups.xml svneol=native#text/xml |
| | | xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/filter/ElementDispatcherTest.java svneol=native#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/util/FeatureTypeBuilderUtilTest.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/util/FileUtilsTest.java -text svneol=unset#text/plain |
| | | xdgnjobs/ximple-spatialjob/src/test/resources/com/ximple/eofms/filter/test-data/testElementFilter.xml svneol=native#text/xml |
| | | xdgnjobs/ximple-spatialjob/src/test/resources/com/ximple/eofms/filter/test-data/testRules.xml svneol=native#text/xml |
| | |
| | | <oracle.jdbc>true</oracle.jdbc> |
| | | <test.maxHeapSize>512M</test.maxHeapSize> |
| | | <src.output>${basedir}/target</src.output> |
| | | <java5>1.5</java5> |
| | | <xdgnio.version>0.9.0</xdgnio.version> |
| | | <gt.version>2.4.4</gt.version> |
| | | <java5>1.6</java5> |
| | | <xdgnio.version>2.1.1</xdgnio.version> |
| | | <gt.version>10.3.x</gt.version> |
| | | <failIfNoTests>false</failIfNoTests> |
| | | <stress.skip.pattern></stress.skip.pattern> |
| | | <online.skip.pattern></online.skip.pattern> |
| | | <java.awt.headless>false</java.awt.headless> |
| | | <allow.test.failure.ignore>false</allow.test.failure.ignore> |
| | | </properties> |
| | | |
| | | <profiles> |
| | |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-javadoc-plugin</artifactId> |
| | | <version>2.6.1</version> |
| | | <configuration> |
| | | <source>1.5</source> |
| | | </configuration> |
| | |
| | | </site> |
| | | </distributionManagement> |
| | | </profile> |
| | | |
| | | <!-- =========================================================== --> |
| | | <!-- Build Configuration --> |
| | | <!-- copies all JARs in a single directory. --> |
| | | <!-- =========================================================== --> |
| | | <profile> |
| | | <id>collect</id> |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>com.ximple.eofms.maven</groupId> |
| | | <artifactId>ximple-jar-collector</artifactId> |
| | | <version>${project.version}</version> |
| | | <executions> |
| | | <execution> |
| | | <goals> |
| | | <goal>collect</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | </profile> |
| | | </profiles> |
| | | |
| | | <scm> |
| | |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-dgnjobs</artifactId> |
| | | <packaging>pom</packaging> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | <name>ximple-dgnjobs</name> |
| | | <url>http://www.ximple.com.tw</url> |
| | | |
| | |
| | | <url>http://www.ximple.com.tw</url> |
| | | </organization> |
| | | |
| | | <inceptionYear>2008</inceptionYear> |
| | | <inceptionYear>2012</inceptionYear> |
| | | |
| | | <!-- =========================================================== --> |
| | | <!-- Issue managements and mailing lists. --> |
| | |
| | | <!-- =========================================================== --> |
| | | <dependencyManagement> |
| | | <dependencies> |
| | | <!-- GeoAPI and its dependencies --> |
| | | <dependency> |
| | | <groupId>org.opengis</groupId> |
| | | <artifactId>geoapi-nogenerics</artifactId> |
| | | <version>2.1.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>javax.units</groupId> |
| | | <artifactId>jsr108</artifactId> |
| | | <version>0.01</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.vividsolutions</groupId> |
| | | <artifactId>jts</artifactId> |
| | | <version>1.9</version> |
| | | <version>1.13</version> |
| | | </dependency> |
| | | |
| | | <!-- Apache --> |
| | |
| | | <dependency> |
| | | <groupId>commons-beanutils</groupId> |
| | | <artifactId>commons-beanutils</artifactId> |
| | | <version>1.7</version> |
| | | <version>1.8.2</version> |
| | | </dependency> |
| | | --> |
| | | <dependency> |
| | |
| | | <version>3.2.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-digester</groupId> |
| | | <artifactId>commons-digester</artifactId> |
| | | <version>1.8</version> |
| | | <groupId>org.apache.commons</groupId> |
| | | <artifactId>commons-digester3</artifactId> |
| | | <version>3.2</version> |
| | | <!--classifier>with-deps</classifier--> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-pool</groupId> |
| | | <artifactId>commons-pool</artifactId> |
| | | <version>1.4</version> |
| | | <version>1.6</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-logging</groupId> |
| | |
| | | <dependency> |
| | | <groupId>commons-cli</groupId> |
| | | <artifactId>commons-cli</artifactId> |
| | | <version>1.1</version> |
| | | <version>1.2</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-io</groupId> |
| | | <artifactId>commons-io</artifactId> |
| | | <version>2.4</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>log4j</groupId> |
| | | <artifactId>log4j</artifactId> |
| | | <version>1.2.15</version> |
| | | <version>1.2.17</version> |
| | | <!-- Same as the dependency in commons-logging --> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | <version>3.1-FINAL</version> |
| | | <version>3.9</version> |
| | | </dependency> |
| | | |
| | | <!-- geotools --> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2</artifactId> |
| | | <artifactId>gt-api</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-api</artifactId> |
| | | <artifactId>gt-main</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-main</artifactId> |
| | | <artifactId>gt-shapefile</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-shapefile</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-sample-data</artifactId> |
| | | <artifactId>gt-sample-data</artifactId> |
| | | <version>${gt.version}</version> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-data</artifactId> |
| | | <artifactId>gt-data</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-jdbc</artifactId> |
| | | <artifactId>gt-opengis</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-oracle-spatial</artifactId> |
| | | <artifactId>gt-metadata</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-postgis</artifactId> |
| | | <artifactId>gt-jdbc</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-mysql</artifactId> |
| | | <groupId>org.geotools.jdbc</groupId> |
| | | <artifactId>gt-jdbc-oracle</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools.jdbc</groupId> |
| | | <artifactId>gt-jdbc-postgis</artifactId> |
| | | <version>${gt.version}</version> |
| | | <!--exclusions> |
| | | <exclusion> |
| | | <groupId>org.postgis</groupId> |
| | | <artifactId>postgis-driver</artifactId> |
| | | </exclusion> |
| | | </exclusions--> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools.jdbc</groupId> |
| | | <artifactId>gt-jdbc-mysql</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- because main and sample-data depend on referencing we need a tie breaker --> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-referencing</artifactId> |
| | | <artifactId>gt-referencing</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt-epsg-hsql</artifactId> |
| | | <version>${gt.version}</version> |
| | | <!--exclusions> |
| | | <exclusion> |
| | | <groupId>com.h2database</groupId> |
| | | <artifactId>h2</artifactId> |
| | | </exclusion> |
| | | </exclusions--> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt-epsg-wkt</artifactId> |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>jdom</groupId> |
| | | <groupId>org.jdom</groupId> |
| | | <artifactId>jdom</artifactId> |
| | | <version>1.0</version> |
| | | <version>1.1.3</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | | <artifactId>velocity</artifactId> |
| | | <version>1.5</version> |
| | | </dependency> |
| | | |
| | | <!-- We need this to make the referencing module useful --> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-epsg-hsql</artifactId> |
| | | <version>${gt.version}</version> |
| | | <scope>test</scope> |
| | | <version>1.7</version> |
| | | </dependency> |
| | | |
| | | <!-- ORACLE --> |
| | |
| | | <dependency> |
| | | <groupId>com.oracle</groupId> |
| | | <artifactId>ojdbc5</artifactId> |
| | | <version>11.1.0</version> |
| | | <version>11.1.0.7.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.oracle</groupId> |
| | |
| | | <version>11.1.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <!--dependency> |
| | | <groupId>postgresql</groupId> |
| | | <artifactId>postgresql</artifactId> |
| | | <version>8.3-603.jdbc3</version> |
| | | </dependency> |
| | | <version>8.4-702.jdbc3</version> |
| | | </dependency--> |
| | | <dependency> |
| | | <groupId>org.postgis</groupId> |
| | | <artifactId>postgis-driver</artifactId> |
| | | <version>1.3.3</version> |
| | | <version>2.0.2</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <!--dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | <version>5.1.6</version> |
| | | </dependency> |
| | | <version>5.1.18</version> |
| | | </dependency--> |
| | | |
| | | <!-- opensymphony --> |
| | | <!--dependency> |
| | | <groupId>com.h2database</groupId> |
| | | <artifactId>h2</artifactId> |
| | | <version>1.3.163</version> |
| | | </dependency--> |
| | | |
| | | <!-- EnterpriseDB --> |
| | | <dependency> |
| | | <groupId>opensymphony</groupId> |
| | | <artifactId>quartz</artifactId> |
| | | <version>1.6.0</version> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>xedb-gt-geospatial</artifactId> |
| | | <version>0.1.1</version> |
| | | </dependency> |
| | | |
| | | <!-- quartz-scheduler--> |
| | | <dependency> |
| | | <groupId>org.quartz-scheduler</groupId> |
| | | <artifactId>quartz</artifactId> |
| | | <version>2.2.1</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-api</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.quartz-scheduler</groupId> |
| | | <artifactId>quartz-jobs</artifactId> |
| | | <version>2.2.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-api</artifactId> |
| | | <version>1.7.5</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-log4j12</artifactId> |
| | | <version>1.7.5</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>jcl-over-slf4j</artifactId> |
| | | <version>1.7.5</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.awl</groupId> |
| | | <artifactId>awl</artifactId> |
| | | <version>1.1.0-rc</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>it.geosolutions</groupId> |
| | | <artifactId>geoserver-manager</artifactId> |
| | | <!--version>1.5.2</version--> |
| | | <version>1.6-SNAPSHOT</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>xerces</groupId> |
| | | <artifactId>xercesImpl</artifactId> |
| | | <version>2.11.0</version> |
| | | </dependency> |
| | | <!-- Tests or legacy --> |
| | | <dependency> |
| | | <groupId>org.testng</groupId> |
| | | <artifactId>testng</artifactId> |
| | | <version>5.8</version> |
| | | <classifier>jdk15</classifier> |
| | | <version>6.8.7</version> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | </dependencies> |
| | |
| | | <!-- Dependencies to be inherited by all modules. --> |
| | | <!-- =========================================================== --> |
| | | <dependencies> |
| | | <dependency> |
| | | <artifactId>geoapi-nogenerics</artifactId> |
| | | <groupId>org.opengis</groupId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <artifactId>jsr108</artifactId> |
| | | <groupId>javax.units</groupId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.vividsolutions</groupId> |
| | | <artifactId>jts</artifactId> |
| | |
| | | <groupId>commons-collections</groupId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-digester</groupId> |
| | | <artifactId>commons-digester</artifactId> |
| | | <groupId>org.apache.commons</groupId> |
| | | <artifactId>commons-digester3</artifactId> |
| | | <!--classifier>with-deps</classifier--> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-pool</groupId> |
| | |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <artifactId>gt2-api</artifactId> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt-api</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <artifactId>gt2-main</artifactId> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt-main</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt-epsg-hsql</artifactId> |
| | | </dependency> |
| | | |
| | | <!--dependency> |
| | | <groupId>com.h2database</groupId> |
| | | <artifactId>h2</artifactId> |
| | | </dependency--> |
| | | |
| | | <dependency> |
| | | <groupId>xerces</groupId> |
| | | <artifactId>xercesImpl</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <artifactId>testng</artifactId> |
| | | <groupId>it.geosolutions</groupId> |
| | | <artifactId>geoserver-manager</artifactId> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>commons-io</groupId> |
| | | <artifactId>commons-io</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.testng</groupId> |
| | | <classifier>jdk15</classifier> |
| | | <artifactId>testng</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | </dependencies> |
| | |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-assembly-plugin</artifactId> |
| | | <version>2.1</version> |
| | | <configuration> |
| | | <descriptors> |
| | | <descriptor>build/maven/assembly/binaryDist.xml</descriptor> |
| | | <descriptor>build/maven/assembly/sourceDist.xml</descriptor> |
| | | </descriptors> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-clean-plugin</artifactId> |
| | | <version>2.1.1</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-clover-plugin</artifactId> |
| | | <version>2.3</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-compiler-plugin</artifactId> |
| | | <version>2.0.2</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-install-plugin</artifactId> |
| | | <version>2.1</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-jar-plugin</artifactId> |
| | | <version>2.1</version> |
| | | <artifactId>maven-eclipse-plugin</artifactId> |
| | | <version>2.5</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-javadoc-plugin</artifactId> |
| | | <version>2.4</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-plugin-plugin</artifactId> |
| | | <version>2.3</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-pmd-plugin</artifactId> |
| | | <version>2.4</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-project-info-reports-plugin</artifactId> |
| | | <version>2.0.1</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-resources-plugin</artifactId> |
| | | <version>2.2</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-site-plugin</artifactId> |
| | | <version>2.0-beta-5</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-surefire-plugin</artifactId> |
| | | <version>2.4.2</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-surefire-report-plugin</artifactId> |
| | | <version>2.4.2</version> |
| | | </plugin> |
| | | |
| | | <!-- http://www.ibiblio.org/maven2/org/codehaus/mojo/ --> |
| | | <plugin> |
| | | <groupId>org.codehaus.mojo</groupId> |
| | | <artifactId>changelog-maven-plugin</artifactId> |
| | | <version>2.0-beta-1</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.codehaus.mojo</groupId> |
| | | <artifactId>changes-maven-plugin</artifactId> |
| | | <version>2.0-beta-1</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.codehaus.mojo</groupId> |
| | | <artifactId>jxr-maven-plugin</artifactId> |
| | | <version>2.0-beta-1</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.codehaus.mojo</groupId> |
| | | <artifactId>taglist-maven-plugin</artifactId> |
| | | <version>2.2</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.codehaus.mojo</groupId> |
| | | <artifactId>jalopy-maven-plugin</artifactId> |
| | | <version>1.0-SNAPSHOT</version> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-source-plugin</artifactId> |
| | | <configuration> |
| | | <outputDirectory>${src.output}</outputDirectory> |
| | | <attach>false</attach> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-eclipse-plugin</artifactId> |
| | | <version>2.4</version> |
| | | <version>2.6.1</version> |
| | | </plugin> |
| | | </plugins> |
| | | </pluginManagement> |
| | | |
| | | <!-- http://www.ibiblio.org/maven2/org/apache/maven/wagon/ --> |
| | | <!-- |
| | | <extensions> |
| | | <extension> |
| | | <groupId>org.apache.maven.wagon</groupId> |
| | |
| | | <version>1.0-beta-2</version> |
| | | </extension> |
| | | </extensions> |
| | | --> |
| | | |
| | | <plugins> |
| | | <!-- ======================================================= --> |
| | |
| | | <convention>gt2/jalopygeotools.xml</convention> |
| | | <failOnError>false</failOnError> |
| | | </configuration> |
| | | <!-- |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.geotools.maven</groupId> |
| | |
| | | <version>${gt.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | --> |
| | | </plugin> |
| | | |
| | | |
| | |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-compiler-plugin</artifactId> |
| | | <configuration> |
| | | <source>1.5</source> |
| | | <source>1.6</source> |
| | | <!-- The -source argument for the Java compiler. --> |
| | | <target>1.5</target> |
| | | <target>1.6</target> |
| | | <!-- The -target argument for the Java compiler. --> |
| | | <debug>true</debug> |
| | | <!-- Whether to include debugging information. --> |
| | | <encoding>ISO-8859-1</encoding> |
| | | <encoding>UTF-8</encoding> |
| | | <!-- The -encoding argument for the Java compiler. --> |
| | | </configuration> |
| | | </plugin> |
| | |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-surefire-plugin</artifactId> |
| | | <version>2.14.1</version> |
| | | <configuration> |
| | | <includes> |
| | | <include>**/*Test.java</include> |
| | |
| | | <!-- ======================================================= --> |
| | | <!-- Code coverage --> |
| | | <!-- ======================================================= --> |
| | | <!-- |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-clover-plugin</artifactId> |
| | | <version>2.4</version> |
| | | <configuration> |
| | | <jdk>1.5</jdk> |
| | | <licenseLocation> |
| | | http://svn.geotools.org/geotools/branches/2.4.x/build/maven/build-configs/src/main/resources/gt2/clover.license |
| | | http://svn.geotools.org/geotools/branches/2.6.x/build/maven/build-configs/src/main/resources/gt2/clover.license |
| | | </licenseLocation> |
| | | <flushPolicy>directed</flushPolicy> |
| | | </configuration> |
| | |
| | | <phase>pre-site</phase> |
| | | <goals> |
| | | <goal>instrument</goal> |
| | | <!-- aggregation is disabled due to the bug: --> |
| | | <!-- http://jira.codehaus.org/browse/MCLOVER-34 --> |
| | | < - aggregation is disabled due to the bug: - !> |
| | | < - http://jira.codehaus.org/browse/MCLOVER-34 - !> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | |
| | | </dependency> |
| | | </dependencies> |
| | | </plugin> |
| | | |
| | | --> |
| | | |
| | | <!-- ======================================================= --> |
| | | <!-- JAR packaging. --> |
| | |
| | | </manifest> |
| | | </archive> |
| | | </configuration> |
| | | </plugin> |
| | | |
| | | <!-- ======================================================= --> |
| | | <!-- JavaDoc packaging. --> |
| | | <!-- ======================================================= --> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-javadoc-plugin</artifactId> |
| | | </plugin> |
| | | |
| | | <!-- ======================================================= --> |
| | |
| | | <uniqueVersion>false</uniqueVersion> |
| | | <id>ximple</id> |
| | | <name>Ximple - Artifactory lib repo</name> |
| | | <url>dav:http://www.ximple.com.tw/artifactory/libs-releases</url> |
| | | <url>dav:http://www.ximple.com.tw/artifactory/libs-releases-local</url> |
| | | </repository> |
| | | <snapshotRepository> |
| | | <uniqueVersion>false</uniqueVersion> |
| | | <id>ximple-snapshots</id> |
| | | <name>Ximple - Artifactory lib-snapshots repo</name> |
| | | <url>dav:http://www.ximple.com.tw/artifactory/libs-snapshots</url> |
| | | <url>dav:http://www.ximple.com.tw/artifactory/libs-snapshots-local</url> |
| | | </snapshotRepository> |
| | | </distributionManagement> |
| | | |
| | |
| | | <module>ximple-dgnio</module> |
| | | <module>ximple-spatialjob</module> |
| | | <module>ximple-jobcarrier</module> |
| | | <module>ximple-elmparser</module> |
| | | <!-- <module>ximple-elmparser</module> --> |
| | | </modules> |
| | | </project> |
| | |
| | | <parent> |
| | | <groupId>com.ximple.eofms.maven</groupId> |
| | | <artifactId>ximple-maven</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | </parent> |
| | | |
| | | |
| | |
| | | <!-- =========================================================== --> |
| | | <groupId>com.ximple.eofms.maven</groupId> |
| | | <artifactId>ximple-jar-collector</artifactId> |
| | | <version>2.1.1</version> |
| | | <packaging>maven-plugin</packaging> |
| | | <name>JAR files collector</name> |
| | | |
| | |
| | | private String jarName; |
| | | |
| | | /** |
| | | * Project dependencies. |
| | | * |
| | | * @parameter expression="${project.artifacts}" |
| | | * @required |
| | | */ |
| | | private Set /*<Artifact>*/ dependencies; |
| | | |
| | | /** |
| | | * The Maven project running this plugin. |
| | | * |
| | | * @parameter expression="${project}" |
| | |
| | | * Gets the parent "target" directory. |
| | | */ |
| | | MavenProject parent = project; |
| | | |
| | | while (parent.hasParent()) { |
| | | parent = parent.getParent(); |
| | | } |
| | | |
| | | collectDirectory = parent.getBuild().getDirectory(); |
| | | |
| | | /* |
| | | * Now collects the JARs. |
| | | */ |
| | |
| | | * such file. Some modules use pom packaging, which do not produce any JAR file. |
| | | */ |
| | | final File jarFile = new File(outputDirectory, jarName + ".jar"); |
| | | |
| | | if (!jarFile.isFile()) { |
| | | return; |
| | | } |
| | | |
| | | /* |
| | | * Get the "target" directory of the parent pom.xml and make sure it exists. |
| | | */ |
| | | File collect = new File(collectDirectory); |
| | | |
| | | if (!collect.exists()) { |
| | | if (!collect.mkdir()) { |
| | | throw new MojoExecutionException("Failed to create target directory."); |
| | | throw new MojoExecutionException("Failed to create target directory: " + collect.getAbsolutePath()); |
| | | } |
| | | } |
| | | |
| | | if (collect.getCanonicalFile().equals(jarFile.getParentFile().getCanonicalFile())) { |
| | | /* |
| | | * The parent's directory is the same one than this module's directory. |
| | |
| | | */ |
| | | return; |
| | | } |
| | | |
| | | /* |
| | | * Creates a "binaries" subdirectory inside the "target" directory. |
| | | */ |
| | | collect = new File(collect, SUB_DIRECTORY); |
| | | |
| | | if (!collect.exists()) { |
| | | if (!collect.mkdir()) { |
| | | throw new MojoExecutionException("Failed to create binaries directory."); |
| | | } |
| | | } |
| | | |
| | | int count = 1; |
| | | FileUtils.copyFileToDirectory(jarFile, collect); |
| | | |
| | | Set<Artifact> dependencies = project.getDependencyArtifacts(); |
| | | if (dependencies != null) { |
| | | for (final Iterator it = dependencies.iterator(); it.hasNext();) { |
| | | final Artifact artifact = (Artifact) it.next(); |
| | | for (final Artifact artifact : dependencies) { |
| | | System.out.println("+++++++++++++++++++++++ DEP: " + artifact.getDependencyTrail()); |
| | | final String scope = artifact.getScope(); |
| | | |
| | | if ((scope != null) // Maven 2.0.6 bug? |
| | | && (scope.equalsIgnoreCase(Artifact.SCOPE_COMPILE) |
| | | || scope.equalsIgnoreCase(Artifact.SCOPE_RUNTIME))) { |
| | | if (scope != null && // Maven 2.0.6 bug? |
| | | (scope.equalsIgnoreCase(Artifact.SCOPE_COMPILE) || |
| | | scope.equalsIgnoreCase(Artifact.SCOPE_RUNTIME))) |
| | | { |
| | | final File file = artifact.getFile(); |
| | | if (!artifact.getGroupId().startsWith("com.ximple.eofms")) { |
| | | final File copy = new File(collect, file.getName()); |
| | | |
| | | if (!copy.exists()) { |
| | | if (copy.exists()) { |
| | | /* |
| | | * Copies the dependency only if it was not already copied. Note that |
| | | * the module's JAR was copied inconditionnaly above (because it may |
| | |
| | | * dependencies list changed, it will be copied inconditionnaly when |
| | | * the module for this JAR will be processed by Maven. |
| | | */ |
| | | continue; |
| | | } |
| | | } |
| | | FileUtils.copyFileToDirectory(file, collect); |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | getLog().info("Copied " + count + " JAR to parent directory."); |
| | | } |
| | | } |
| | |
| | | <parent> |
| | | <groupId>com.ximple.eofms.maven</groupId> |
| | | <artifactId>ximple-build</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | </parent> |
| | | |
| | | |
| | |
| | | <dependency> |
| | | <groupId>org.apache.maven</groupId> |
| | | <artifactId>maven-plugin-api</artifactId> |
| | | <version>2.0.4</version> |
| | | <version>2.2.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.maven</groupId> |
| | | <artifactId>maven-project</artifactId> |
| | | <version>2.0.4</version> |
| | | <version>2.2.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.codehaus.plexus</groupId> |
| | | <artifactId>plexus-utils</artifactId> |
| | | <version>1.2</version> |
| | | <version>2.1</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | |
| | | <parent> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-dgnjobs</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | </parent> |
| | | |
| | | |
| | |
| | | <!-- =========================================================== --> |
| | | <groupId>com.ximple.eofms.maven</groupId> |
| | | <artifactId>ximple-build</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | <packaging>pom</packaging> |
| | | <name>Build tools for Ximple DgnJobs</name> |
| | | |
| | |
| | | <parent> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-dgnjobs</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | </parent> |
| | | |
| | | <!-- =========================================================== --> |
| | |
| | | <!-- =========================================================== --> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-dgnio</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | <packaging>jar</packaging> |
| | | <name>ximple-dgnio</name> |
| | | <url>http://www.ximple.com.tw</url> |
| | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-sample-data</artifactId> |
| | | <artifactId>gt-sample-data</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-io</groupId> |
| | | <artifactId>commons-io</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <!-- =========================================================== --> |
| | |
| | | |
| | | import org.apache.log4j.Logger; |
| | | |
| | | import com.vividsolutions.jts.algorithm.Angle; |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/26 ¤U¤È 06:41:45 |
| | | * @since 2006/5/26 �U�� 06:41:45 |
| | | */ |
| | | public class ArcElement extends Element implements GeometryConverter |
| | | { |
| | | public class ArcElement extends Element implements GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(ArcElement.class); |
| | | |
| | | public ArcElement(byte[] raw) |
| | | { |
| | | ArcElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public double getStartAngle() |
| | | { |
| | | public double getStartAngle() { |
| | | int angle = (raw[18] & 0x0000ffff) << 16 | (raw[19] & 0x0000ffff); |
| | | return DgnUtility.converIntToRotation(angle); |
| | | } |
| | | |
| | | public void setStartAngle(double value) |
| | | { |
| | | public void setStartAngle(double value) { |
| | | int angle = DgnUtility.converRotatioToInt(value); |
| | | |
| | | raw[18] = (short) (angle >>> 16 & 0x0000ffff); |
| | | raw[19] = (short) (angle & 0x0000ffff); |
| | | } |
| | | |
| | | public double getSweepAngle() |
| | | { |
| | | public double getSweepAngle() { |
| | | int angle = (raw[20] & 0x0000ffff) << 16 | (raw[21] & 0x0000ffff); |
| | | if (angle < 0) |
| | | angle = -1 * (angle & 0x7fffffff); |
| | |
| | | return DgnUtility.converIntToRotation(angle); |
| | | } |
| | | |
| | | public void setSweepAngle(double value) |
| | | { |
| | | public void setSweepAngle(double value) { |
| | | int angle = DgnUtility.converRotatioToInt(value); |
| | | if (angle < 0) |
| | | { |
| | | if (angle < 0) { |
| | | angle &= 0x7fffffff; |
| | | angle |= 0x80000000; |
| | | } |
| | |
| | | raw[21] = (short) (angle & 0x0000ffff); |
| | | } |
| | | |
| | | public double getPrimary() |
| | | { |
| | | public double getPrimary() { |
| | | rawBuffer.position(22 * 2); |
| | | ByteOrder bo = rawBuffer.order(); |
| | | rawBuffer.order(ByteOrder.BIG_ENDIAN); |
| | |
| | | return DgnUtility.convertDGNToIEEEDouble(primary) / 1000.0; |
| | | } |
| | | |
| | | public void setPrimary(double value) |
| | | { |
| | | public void setPrimary(double value) { |
| | | double temp = value * 1000.0; |
| | | short[] primary = DgnUtility.convertIEEEDoubleToDGN(temp); |
| | | |
| | | System.arraycopy(primary, 0, raw, 22, 4); |
| | | } |
| | | |
| | | public double getSecondary() |
| | | { |
| | | public double getSecondary() { |
| | | rawBuffer.position(26 * 2); |
| | | ByteOrder bo = rawBuffer.order(); |
| | | rawBuffer.order(ByteOrder.BIG_ENDIAN); |
| | |
| | | return DgnUtility.convertDGNToIEEEDouble(secondary) / 1000.0; |
| | | } |
| | | |
| | | public void setSecondary(double value) |
| | | { |
| | | public void setSecondary(double value) { |
| | | double temp = value * 1000.0; |
| | | short[] secondary = DgnUtility.convertIEEEDoubleToDGN(temp); |
| | | |
| | | System.arraycopy(secondary, 0, raw, 26, 4); |
| | | } |
| | | |
| | | public double getRotationAngle() |
| | | { |
| | | public double getRotationAngle() { |
| | | int rotation = (raw[30] << 16 & 0xffff0000); |
| | | rotation |= raw[31] & 0x0000ffff; |
| | | |
| | | return DgnUtility.converIntToRotation(rotation); |
| | | } |
| | | |
| | | public void setRotationAngle(double value) |
| | | { |
| | | public void setRotationAngle(double value) { |
| | | int angle = DgnUtility.converRotatioToInt(value); |
| | | |
| | | raw[30] = (short) (angle >> 16 & 0x0000ffff); |
| | | raw[31] = (short) (angle & 0x0000ffff); |
| | | } |
| | | |
| | | public Coordinate getOrigin() |
| | | { |
| | | public Coordinate getOrigin() { |
| | | rawBuffer.position(32 * 2); |
| | | ByteOrder bo = rawBuffer.order(); |
| | | rawBuffer.order(ByteOrder.BIG_ENDIAN); |
| | |
| | | return new Coordinate(dx, dy); |
| | | } |
| | | |
| | | public void setOrigin(Coordinate value) |
| | | { |
| | | public void setOrigin(Coordinate value) { |
| | | double temp = DgnUtility.converCoordToUnit(value.x); |
| | | short[] x = DgnUtility.convertIEEEDoubleToDGN(temp); |
| | | |
| | |
| | | System.arraycopy(y, 0, raw, 36, 4); |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | double sweep = getSweepAngle(); |
| | | double temp = Math.abs(sweep); |
| | | temp /= 4; |
| | |
| | | return factory.createLineString(convertToLineString(pts)); |
| | | } |
| | | |
| | | private Coordinate[] convertToLineString(int pts) |
| | | { |
| | | private double validAngle(double value) { |
| | | if (value < 0.0) value += 360.0; |
| | | else if (value > 360.0) value -= 360.0; |
| | | |
| | | return value; |
| | | } |
| | | |
| | | private Coordinate[] convertToLineString(int pts) { |
| | | ArrayList<Coordinate> result = new ArrayList<Coordinate>(); |
| | | double beta = DgnUtility.converRotationToRadian(-getRotationAngle()); |
| | | double startAngle = getStartAngle(); |
| | | double sweepAngle = getSweepAngle(); |
| | | double endAngle = startAngle + sweepAngle; |
| | | double rotation = validAngle(360 - getRotationAngle()); |
| | | double beta = Angle.toRadians(-rotation); |
| | | double startAngle = validAngle(getStartAngle()); |
| | | double sweepAngle = Math.abs(getSweepAngle()); |
| | | boolean clockwise = (getSweepAngle() < 0.0); |
| | | double endAngle = validAngle(startAngle + getSweepAngle()); |
| | | double steps = sweepAngle / pts; |
| | | |
| | | double current; |
| | | if (sweepAngle < 0) |
| | | { |
| | | for (current = startAngle; current > endAngle; current += steps) |
| | | { |
| | | for (int i = 0; i < pts; i++) { |
| | | if (clockwise) |
| | | current = startAngle - i * steps; |
| | | else |
| | | current = startAngle + i * steps; |
| | | |
| | | current = validAngle(current); |
| | | Coordinate pt = computePointOnArcByAngle(beta, current); |
| | | result.add(pt); |
| | | } |
| | | |
| | | } else |
| | | { |
| | | for (current = startAngle; current < endAngle; current += steps) |
| | | { |
| | | current = validAngle(endAngle); |
| | | Coordinate pt = computePointOnArcByAngle(beta, current); |
| | | result.add(pt); |
| | | } |
| | | } |
| | | |
| | | Coordinate pt = computePointOnArcByAngle(beta, endAngle); |
| | | result.add(pt); |
| | | |
| | | return result.toArray(new Coordinate[result.size()]); |
| | | } |
| | | |
| | | private Coordinate computePointOnArcByAngle(double beta, double current) |
| | | { |
| | | private Coordinate computePointOnArcByAngle(double beta, double angle) { |
| | | double sinbeta = Math.sin(beta); |
| | | double cosbeta = Math.cos(beta); |
| | | Coordinate pt = new Coordinate(); |
| | | double alpha = DgnUtility.converRotationToRadian(current); |
| | | double alpha = Angle.toRadians(angle); |
| | | double sinalpha = Math.sin(alpha); |
| | | double cosalpha = Math.cos(alpha); |
| | | |
| | | Coordinate pt = new Coordinate(); |
| | | pt.x = getOrigin().x + (getPrimary() * cosalpha * cosbeta - |
| | | getSecondary() * sinalpha * sinbeta); |
| | | pt.y = getOrigin().y + (getPrimary() * cosalpha * sinbeta + |
| | |
| | | return pt; |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.ARC); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new ArcElement(raw); |
| | | } |
| | | } |
| | |
| | | package com.ximple.io.dgn7; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.LineString; |
| | | import com.vividsolutions.jts.geom.LinearRing; |
| | | |
| | | /** |
| | | * ComplexChainElement |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 03:44:56 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public class ComplexChainElement extends Element implements ComplexElement, GeometryConverter |
| | | { |
| | | public class ComplexChainElement extends Element implements ComplexElement, GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(ComplexChainElement.class); |
| | | |
| | | protected ArrayList<Element> list = new ArrayList<Element>(); |
| | | |
| | | public ComplexChainElement(byte[] raw) |
| | | { |
| | | ComplexChainElement(byte[] raw) { |
| | | super(raw); |
| | | attrOffset = 4; |
| | | } |
| | | |
| | | public int size() |
| | | { |
| | | public int size() { |
| | | return list.size(); |
| | | } |
| | | |
| | | public boolean isEmpty() |
| | | { |
| | | public boolean isEmpty() { |
| | | return list.isEmpty(); |
| | | } |
| | | |
| | | public boolean contains(Object o) |
| | | { |
| | | public boolean contains(Object o) { |
| | | return list.contains(o); |
| | | } |
| | | |
| | | public Iterator iterator() |
| | | { |
| | | public Iterator iterator() { |
| | | return list.iterator(); |
| | | } |
| | | |
| | | public Object[] toArray() |
| | | { |
| | | public Object[] toArray() { |
| | | return list.toArray(); |
| | | } |
| | | |
| | | public <T> T[] toArray(T[] ts) |
| | | { |
| | | public <T> T[] toArray(T[] ts) { |
| | | return list.toArray(ts); |
| | | } |
| | | |
| | | public boolean add(Element element) |
| | | { |
| | | public boolean add(Element element) { |
| | | return list.add(element); |
| | | } |
| | | |
| | | public boolean remove(Object o) |
| | | { |
| | | public boolean remove(Object o) { |
| | | return list.remove(o); |
| | | } |
| | | |
| | | public boolean containsAll(Collection<?> objects) |
| | | { |
| | | public boolean containsAll(Collection<?> objects) { |
| | | return list.containsAll(objects); |
| | | } |
| | | |
| | | public boolean addAll(Collection<? extends Element> elements) |
| | | { |
| | | public boolean addAll(Collection<? extends Element> elements) { |
| | | return list.addAll(elements); |
| | | } |
| | | |
| | | public boolean addAll(int i, Collection<? extends Element> elements) |
| | | { |
| | | public boolean addAll(int i, Collection<? extends Element> elements) { |
| | | return list.addAll(i, elements); |
| | | } |
| | | |
| | | public boolean removeAll(Collection<?> objects) |
| | | { |
| | | public boolean removeAll(Collection<?> objects) { |
| | | return list.removeAll(objects); |
| | | } |
| | | |
| | | public boolean retainAll(Collection<?> objects) |
| | | { |
| | | public boolean retainAll(Collection<?> objects) { |
| | | return list.retainAll(objects); |
| | | } |
| | | |
| | | public void clear() |
| | | { |
| | | public void clear() { |
| | | list.clear(); |
| | | } |
| | | |
| | | public Element get(int index) |
| | | { |
| | | public Element get(int index) { |
| | | return list.get(index); |
| | | } |
| | | |
| | | public Element set(int i, Element element) |
| | | { |
| | | public Element set(int i, Element element) { |
| | | return list.set(i, element); |
| | | } |
| | | |
| | | public void add(int i, Element element) |
| | | { |
| | | public void add(int i, Element element) { |
| | | list.add(i, element); |
| | | } |
| | | |
| | | public Element remove(int index) |
| | | { |
| | | public Element remove(int index) { |
| | | return list.remove(index); |
| | | } |
| | | |
| | | public int indexOf(Object o) |
| | | { |
| | | public int indexOf(Object o) { |
| | | return list.indexOf(o); |
| | | } |
| | | |
| | | public int lastIndexOf(Object o) |
| | | { |
| | | public int lastIndexOf(Object o) { |
| | | return list.lastIndexOf(o); |
| | | } |
| | | |
| | | public ListIterator listIterator() |
| | | { |
| | | public ListIterator listIterator() { |
| | | return list.listIterator(); |
| | | } |
| | | |
| | | public ListIterator listIterator(int index) |
| | | { |
| | | public ListIterator listIterator(int index) { |
| | | return list.listIterator(index); |
| | | } |
| | | |
| | | public List subList(int fromIndex, int toIndex) |
| | | { |
| | | public List subList(int fromIndex, int toIndex) { |
| | | return list.subList(fromIndex, toIndex); |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | ArrayList<LineString> lineStrings = new ArrayList<LineString>(); |
| | | |
| | | for (ListIterator it = listIterator(); it.hasNext();) |
| | | { |
| | | for (ListIterator it = listIterator(); it.hasNext();) { |
| | | Element element = (Element) it.next(); |
| | | |
| | | if (element instanceof LineStringElement) |
| | | { |
| | | if (((LineStringElement) element).getVerticeSize() == 0 || ((LineStringElement) element).getVerticeSize() > 1) |
| | | { |
| | | if (element instanceof ShapeElement) { |
| | | if (((ShapeElement) element).getVerticeSize() == 0 || ((ShapeElement) element).getVerticeSize() > 1) { |
| | | lineStrings.add((LinearRing) ((ShapeElement) element).toGeometry(factory)); |
| | | } |
| | | } else if (element instanceof LineStringElement) { |
| | | if (((LineStringElement) element).getVerticeSize() == 0 || ((LineStringElement) element).getVerticeSize() > 1) { |
| | | lineStrings.add((LineString) ((LineStringElement) element).toGeometry(factory)); |
| | | } |
| | | |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | } else if (element instanceof LineElement) { |
| | | |
| | | if (((LineElement) element).getVertices().length == 0 || ((LineElement) element).getVertices().length > 1) |
| | | { |
| | | if (((LineElement) element).getVertices().length == 0 || ((LineElement) element).getVertices().length > 1) { |
| | | lineStrings.add((LineString) ((LineElement) element).toGeometry(factory)); |
| | | } |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | } else if (element instanceof ArcElement) { |
| | | lineStrings.add((LineString) ((ArcElement) element).toGeometry(factory)); |
| | | } else { |
| | | logger.warn("Unknown sub-element in ComplexChain Element-" + element.getElementType()); |
| | |
| | | return factory.createMultiLineString(lines); |
| | | } |
| | | |
| | | public double getElementSize() |
| | | { |
| | | public short getTotalLength() { |
| | | return raw[18]; |
| | | } |
| | | |
| | | public boolean isClosed() |
| | | { |
| | | if (isEmpty()) |
| | | { |
| | | protected void setTotalLength(short value) { |
| | | raw[18] = value; |
| | | } |
| | | |
| | | public short getNumOfElement() { |
| | | return raw[19]; |
| | | } |
| | | |
| | | protected void setNumOfElement(short value) { |
| | | raw[19] = value; |
| | | } |
| | | |
| | | |
| | | public short[] getAttributes() { |
| | | return Arrays.copyOfRange(raw, 20, 23); |
| | | } |
| | | |
| | | protected void setAttributes(short[] values) { |
| | | if (values.length < 4) return; |
| | | System.arraycopy(values, 0, raw, 20, 24 - 20); |
| | | } |
| | | |
| | | public boolean isClosed() { |
| | | if (isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.COMPLEXCHAIN); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new ComplexChainElement(raw); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 04:17:37 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public interface ComplexElement extends List<Element> |
| | | { |
| | | public interface ComplexElement extends List<Element> { |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 03:45:15 |
| | | * @since 2006/5/18 �U�� 03:45:15 |
| | | */ |
| | | public class ComplexShapeElement extends Element implements ComplexElement, GeometryConverter |
| | | { |
| | | public class ComplexShapeElement extends Element implements ComplexElement, GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(ComplexShapeElement.class); |
| | | |
| | | ArrayList<Element> list = new ArrayList<Element>(); |
| | | |
| | | public ComplexShapeElement(byte[] raw) |
| | | { |
| | | ComplexShapeElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public int size() |
| | | { |
| | | public int size() { |
| | | return list.size(); |
| | | } |
| | | |
| | | public boolean isEmpty() |
| | | { |
| | | public boolean isEmpty() { |
| | | return list.isEmpty(); |
| | | } |
| | | |
| | | public boolean contains(Object o) |
| | | { |
| | | public boolean contains(Object o) { |
| | | return list.contains(o); |
| | | } |
| | | |
| | | public Iterator iterator() |
| | | { |
| | | public Iterator iterator() { |
| | | return list.iterator(); |
| | | } |
| | | |
| | | public Object[] toArray() |
| | | { |
| | | public Object[] toArray() { |
| | | return list.toArray(); |
| | | } |
| | | |
| | | public <T> T[] toArray(T[] ts) |
| | | { |
| | | public <T> T[] toArray(T[] ts) { |
| | | return list.toArray(ts); |
| | | } |
| | | |
| | | public boolean add(Element element) |
| | | { |
| | | public boolean add(Element element) { |
| | | return list.add(element); |
| | | } |
| | | |
| | | public boolean remove(Object o) |
| | | { |
| | | public boolean remove(Object o) { |
| | | return list.remove(o); |
| | | } |
| | | |
| | | public boolean containsAll(Collection<?> objects) |
| | | { |
| | | public boolean containsAll(Collection<?> objects) { |
| | | return list.containsAll(objects); |
| | | } |
| | | |
| | | public boolean addAll(Collection<? extends Element> elements) |
| | | { |
| | | public boolean addAll(Collection<? extends Element> elements) { |
| | | return list.addAll(elements); |
| | | } |
| | | |
| | | public boolean addAll(int i, Collection<? extends Element> elements) |
| | | { |
| | | public boolean addAll(int i, Collection<? extends Element> elements) { |
| | | return list.addAll(i, elements); |
| | | } |
| | | |
| | | public boolean removeAll(Collection<?> objects) |
| | | { |
| | | public boolean removeAll(Collection<?> objects) { |
| | | return list.removeAll(objects); |
| | | } |
| | | |
| | | public boolean retainAll(Collection<?> objects) |
| | | { |
| | | public boolean retainAll(Collection<?> objects) { |
| | | return list.retainAll(objects); |
| | | } |
| | | |
| | | public void clear() |
| | | { |
| | | public void clear() { |
| | | list.clear(); |
| | | } |
| | | |
| | | public Element get(int index) |
| | | { |
| | | public Element get(int index) { |
| | | return list.get(index); |
| | | } |
| | | |
| | | public Element set(int i, Element element) |
| | | { |
| | | public Element set(int i, Element element) { |
| | | return list.set(i, element); |
| | | } |
| | | |
| | | public void add(int i, Element element) |
| | | { |
| | | public void add(int i, Element element) { |
| | | list.add(i, element); |
| | | } |
| | | |
| | | public Element remove(int index) |
| | | { |
| | | public Element remove(int index) { |
| | | return list.remove(index); |
| | | } |
| | | |
| | | public int indexOf(Object o) |
| | | { |
| | | public int indexOf(Object o) { |
| | | return list.indexOf(o); |
| | | } |
| | | |
| | | public int lastIndexOf(Object o) |
| | | { |
| | | public int lastIndexOf(Object o) { |
| | | return list.lastIndexOf(o); |
| | | } |
| | | |
| | | public ListIterator listIterator() |
| | | { |
| | | public ListIterator listIterator() { |
| | | return list.listIterator(); |
| | | } |
| | | |
| | | public ListIterator listIterator(int index) |
| | | { |
| | | public ListIterator listIterator(int index) { |
| | | return list.listIterator(index); |
| | | } |
| | | |
| | | public List subList(int fromIndex, int toIndex) |
| | | { |
| | | public List subList(int fromIndex, int toIndex) { |
| | | return list.subList(fromIndex, toIndex); |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | ArrayList<Geometry> list = new ArrayList<Geometry>(); |
| | | |
| | | for (ListIterator it = listIterator(); it.hasNext();) |
| | | { |
| | | for (ListIterator it = listIterator(); it.hasNext();) { |
| | | Element element = (Element) it.next(); |
| | | |
| | | if (element instanceof ShapeElement) |
| | | { |
| | | if (((ShapeElement) element).getVerticeSize() == 0 || ((ShapeElement) element).getVerticeSize() > 1) |
| | | { |
| | | if (element instanceof ShapeElement) { |
| | | if (((ShapeElement) element).getVerticeSize() == 0 || ((ShapeElement) element).getVerticeSize() > 1) { |
| | | list.add(((ShapeElement) element).toGeometry(factory)); |
| | | } |
| | | } else if (element instanceof LineStringElement) |
| | | { |
| | | if (((LineStringElement) element).getVerticeSize() == 0 || ((LineStringElement) element).getVerticeSize() > 1) |
| | | { |
| | | } else if (element instanceof LineStringElement) { |
| | | if (((LineStringElement) element).getVerticeSize() == 0 || ((LineStringElement) element).getVerticeSize() > 1) { |
| | | list.add(((LineStringElement) element).toGeometry(factory)); |
| | | } |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | if (((LineElement) element).getVertices().length == 0 || ((LineElement) element).getVertices().length > 1) |
| | | { |
| | | } else if (element instanceof LineElement) { |
| | | if (((LineElement) element).getVertices().length == 0 || ((LineElement) element).getVertices().length > 1) { |
| | | list.add(((LineElement) element).toGeometry(factory)); |
| | | } |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | } else if (element instanceof ArcElement) { |
| | | } |
| | | } |
| | | |
| | | |
| | | CoordinateList pts = new CoordinateList(); |
| | | for (Geometry geom : list) |
| | | { |
| | | for (Geometry geom : list) { |
| | | pts.add(geom.getCoordinates(), true); |
| | | } |
| | | |
| | | return factory.createLinearRing(pts.toCoordinateArray()); |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.COMPLEXSHAPE); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new ComplexShapeElement(raw); |
| | | } |
| | | } |
| | |
| | | package com.ximple.io.dgn7; |
| | | |
| | | |
| | | public class Dgn7Exception extends Exception |
| | | { |
| | | public Dgn7Exception() |
| | | { |
| | | public class Dgn7Exception extends Exception { |
| | | public Dgn7Exception() { |
| | | } |
| | | |
| | | public Dgn7Exception(String s) |
| | | { |
| | | public Dgn7Exception(String s) { |
| | | super(s); |
| | | } |
| | | |
| | | public Dgn7Exception(String s, Throwable throwable) |
| | | { |
| | | public Dgn7Exception(String s, Throwable throwable) { |
| | | super(s, throwable); |
| | | } |
| | | |
| | | public Dgn7Exception(Throwable throwable) |
| | | { |
| | | public Dgn7Exception(Throwable throwable) { |
| | | super(throwable); |
| | | } |
| | | } |
| | |
| | | * Dgn7OracleReader |
| | | * User: Ulysses |
| | | * Date: 2007/10/24 |
| | | * Time: ¤U¤È 01:01:08 |
| | | * Time: |
| | | */ |
| | | public class Dgn7OracleReader implements Iterator<Element> |
| | | { |
| | | public class Dgn7OracleReader implements Iterator<Element> { |
| | | private final static Logger logger = Logger.getLogger(Dgn7OracleReader.class); |
| | | |
| | | private String _sql; |
| | |
| | | private static final int FETCHSIZE = 20; |
| | | private Element _element; |
| | | |
| | | public Dgn7OracleReader(String sql, String fieldName, OracleConnection connection) |
| | | { |
| | | public Dgn7OracleReader(String sql, String fieldName, OracleConnection connection) { |
| | | this._sql = sql; |
| | | this._fieldName = fieldName; |
| | | this._connection = connection; |
| | | } |
| | | |
| | | public String getSql() |
| | | { |
| | | public String getSql() { |
| | | return _sql; |
| | | } |
| | | |
| | | public void setSql(String sql) |
| | | { |
| | | public void setSql(String sql) { |
| | | this._sql = sql; |
| | | } |
| | | |
| | | public String getFieldName() |
| | | { |
| | | public String getFieldName() { |
| | | return _fieldName; |
| | | } |
| | | |
| | | public void setFieldName(String fieldName) |
| | | { |
| | | public void setFieldName(String fieldName) { |
| | | this._fieldName = fieldName; |
| | | } |
| | | |
| | | public boolean hasNext() |
| | | { |
| | | if (_resultSet == null) |
| | | { |
| | | try |
| | | { |
| | | public boolean hasNext() { |
| | | if (_resultSet == null) { |
| | | try { |
| | | initializeReader(); |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | throw new RuntimeException("initialize oralce error.", e); |
| | | } catch (Dgn7Exception e) |
| | | { |
| | | } catch (Dgn7Exception e) { |
| | | throw new RuntimeException("initialize oralce error.", e); |
| | | } |
| | | } |
| | | return _element != null; |
| | | } |
| | | |
| | | public Element next() |
| | | { |
| | | public Element next() { |
| | | Element result = _element; |
| | | |
| | | try |
| | | { |
| | | try { |
| | | fetchElement(); |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | throw new RuntimeException("Error:" + e.getMessage(), e); |
| | | } catch (Dgn7Exception e) |
| | | { |
| | | } catch (Dgn7Exception e) { |
| | | throw new RuntimeException("Error:" + e.getMessage(), e); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public void remove() |
| | | { |
| | | public void remove() { |
| | | throw new RuntimeException("Not Support this method."); |
| | | } |
| | | |
| | | private boolean initializeReader() throws SQLException, Dgn7Exception |
| | | { |
| | | private boolean initializeReader() throws SQLException, Dgn7Exception { |
| | | if (_resultSet != null) return true; |
| | | Statement stmtSrc = _connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | private boolean fetchElement() throws SQLException, Dgn7Exception |
| | | { |
| | | if (_resultSet.next()) |
| | | { |
| | | private boolean fetchElement() throws SQLException, Dgn7Exception { |
| | | if (_resultSet.next()) { |
| | | byte[] raw = null; |
| | | Object value = _resultSet.getObject(this._fieldName); |
| | | |
| | | if (value instanceof BLOB) |
| | | { |
| | | if (value instanceof BLOB) { |
| | | BLOB blob = (BLOB) value; |
| | | |
| | | try |
| | | { |
| | | try { |
| | | raw = getBytesFromBLOB(blob); |
| | | } catch (IOException e) |
| | | { |
| | | } catch (IOException e) { |
| | | throw new Dgn7Exception("IOError", e); |
| | | } |
| | | blob.close(); |
| | | } else if (value instanceof byte[]) |
| | | { |
| | | // blob.close(); |
| | | } else if (value instanceof byte[]) { |
| | | raw = (byte[]) value; |
| | | } |
| | | if (raw == null) |
| | | { |
| | | if (raw == null) { |
| | | _element = null; |
| | | return false; |
| | | } |
| | |
| | | ElementType recordType = ElementType.forID(type); |
| | | IElementHandler handler = recordType.getElementHandler(); |
| | | _element = (Element) handler.read(buffer, signature, elementLength); |
| | | if (recordType.isComplexElement() && (elementLength < raw.length)) |
| | | { |
| | | if (recordType.isComplexElement() && (elementLength < raw.length)) { |
| | | int offset = elementLength; |
| | | while (offset < (raw.length - 4)) |
| | | { |
| | | while (offset < (raw.length - 4)) { |
| | | buffer.position(offset); |
| | | signature = buffer.getShort(); |
| | | type = (byte) ((signature >>> 8) & 0x007f); |
| | | elementLength = (buffer.getShort() * 2) + 4; |
| | | if (raw.length < (offset + elementLength)) |
| | | { |
| | | if (raw.length < (offset + elementLength)) { |
| | | System.out.println("Length not match:" + offset + ":" + buffer.position() + ":" + buffer.limit()); |
| | | break; |
| | | } |
| | | recordType = ElementType.forID(type); |
| | | handler = recordType.getElementHandler(); |
| | | if (handler != null) |
| | | { |
| | | if (handler != null) { |
| | | Element subElement = (Element) handler.read(buffer, signature, elementLength); |
| | | ((ComplexElement) _element).add(subElement); |
| | | offset += elementLength; |
| | | } else |
| | | { |
| | | } else { |
| | | byte[] remain = new byte[buffer.remaining()]; |
| | | System.arraycopy(raw, offset, remain, 0, buffer.remaining()); |
| | | for (int i = 0; i < remain.length; i++) |
| | | { |
| | | if (remain[i] != 0) |
| | | { |
| | | for (int i = 0; i < remain.length; i++) { |
| | | if (remain[i] != 0) { |
| | | logger.info("fetch element has some error. index=" + (offset + i) + ":value=" + remain[i]); |
| | | System.out.println("fetch element has some error. index=" + (offset + i) + ":value=" + remain[i]); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | } else |
| | | { |
| | | } else { |
| | | _element = null; |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | protected static byte[] getBytesFromBLOB(BLOB blob) throws SQLException, IOException |
| | | { |
| | | protected byte[] getBytesFromBLOB(BLOB blob) throws SQLException, IOException { |
| | | byte[] raw; |
| | | |
| | | // BLOB blob = (BLOB) rs.getBlob(1); |
| | |
| | | ByteBuffer buffer = null; // ByteBuffer.allocate(optimalSize); |
| | | int len; |
| | | |
| | | try |
| | | { |
| | | while ((len = (is.read(chunk))) != -1) |
| | | { |
| | | if (buffer != null) |
| | | { |
| | | try { |
| | | while ((len = (is.read(chunk))) != -1) { |
| | | if (buffer != null) { |
| | | buffer.limit(buffer.limit() + len); |
| | | } else |
| | | { |
| | | } else { |
| | | buffer = ByteBuffer.allocate(len); |
| | | } |
| | | |
| | | buffer.put(chunk); |
| | | } |
| | | |
| | | is.close(); |
| | | assert buffer != null; |
| | | buffer.position(0); |
| | | raw = buffer.array(); |
| | | } catch (IOException e) |
| | | { |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | throw e; |
| | | } finally { |
| | | try { |
| | | is.close(); |
| | | } catch (IOException e) { |
| | | logger.warn("InputStream cannot close", e); |
| | | } |
| | | ; |
| | | } |
| | | |
| | | return raw; |
| | |
| | | package com.ximple.io.dgn7; |
| | | |
| | | public class Dgn7fileException extends Dgn7Exception |
| | | { |
| | | public class Dgn7fileException extends Dgn7Exception { |
| | | |
| | | public Dgn7fileException() |
| | | { |
| | | public Dgn7fileException() { |
| | | } |
| | | |
| | | public Dgn7fileException(String message) |
| | | { |
| | | public Dgn7fileException(String message) { |
| | | super(message); |
| | | } |
| | | |
| | | public Dgn7fileException(String message, Throwable cause) |
| | | { |
| | | public Dgn7fileException(String message, Throwable cause) { |
| | | super(message, cause); |
| | | } |
| | | |
| | | public Dgn7fileException(Throwable cause) |
| | | { |
| | | public Dgn7fileException(Throwable cause) { |
| | | super(cause); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/17 ¤U¤È 01:21:00 |
| | | * @since 2006/5/17 |
| | | */ |
| | | public class Dgn7fileHeader |
| | | { |
| | | public class Dgn7fileHeader { |
| | | private short elmtype; |
| | | private byte[] raw; |
| | | |
| | | public Dgn7fileHeader() |
| | | { |
| | | public Dgn7fileHeader() { |
| | | } |
| | | |
| | | public void read(ByteBuffer file, boolean strict) throws IOException |
| | | { |
| | | public void read(ByteBuffer file, boolean strict) throws IOException { |
| | | file.order(ByteOrder.LITTLE_ENDIAN); |
| | | elmtype = file.getShort(); |
| | | |
| | | short wtf = file.getShort(); |
| | | int length = (wtf * 2); |
| | | |
| | | if (file.remaining() != (length)) |
| | | { |
| | | if (file.remaining() != (length)) { |
| | | Assert.shouldNeverReachHere(); |
| | | } |
| | | |
| | |
| | | file.get(raw, 0, file.remaining()); |
| | | } |
| | | |
| | | public String toString() |
| | | { |
| | | public String toString() { |
| | | return "Dgn7fileHeader{" + "raw=" + ((raw == null) ? "null" : raw.length) + '}'; |
| | | } |
| | | |
| | | public int size() |
| | | { |
| | | if (raw == null) |
| | | { |
| | | public int size() { |
| | | if (raw == null) { |
| | | return 0; |
| | | } |
| | | |
| | |
| | | |
| | | //~--- JDK imports ------------------------------------------------------------ |
| | | |
| | | import javax.swing.JFileChooser; |
| | | import javax.swing.JFrame; |
| | | import java.io.EOFException; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | |
| | | import java.nio.MappedByteBuffer; |
| | | import java.nio.channels.FileChannel; |
| | | import java.nio.channels.ReadableByteChannel; |
| | | import javax.swing.JFileChooser; |
| | | import javax.swing.JFrame; |
| | | |
| | | import org.apache.log4j.LogManager; |
| | | import org.apache.log4j.Logger; |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/17 ¤U¤È 01:24:10 |
| | | * @since 2006/5/17 |
| | | */ |
| | | public class Dgn7fileReader |
| | | { |
| | | public class Dgn7fileReader { |
| | | private static final Logger logger = LogManager.getLogger(Dgn7fileReader.class); |
| | | |
| | | private Dgn7fileHeader header; |
| | |
| | | ByteBuffer buffer; |
| | | private ElementType fileElementType = ElementType.UNDEFINED; |
| | | private ByteBuffer headerTransfer; |
| | | private final Record record = new Record(); |
| | | private final Element.FileRecord record = new Element.FileRecord(); |
| | | private final boolean randomAccessEnabled; |
| | | private Lock lock; |
| | | private boolean useMemoryMappedBuffer; |
| | | private long currentOffset = 0L; |
| | | private StreamLogging streamLogger = new StreamLogging("Shapefile Reader"); |
| | | private StreamLogging streamLogger = new StreamLogging("Dgn7 Reader"); |
| | | private int maxElementId = 0; |
| | | |
| | | public Dgn7fileReader(ReadableByteChannel channel, boolean strict, boolean useMemoryMapped, Lock lock) |
| | | throws IOException, Dgn7fileException |
| | | { |
| | | public Dgn7fileReader(FileChannel channel, boolean strict, boolean useMemoryMapped, Lock lock) |
| | | throws IOException, Dgn7fileException { |
| | | this.channel = channel; |
| | | this.useMemoryMappedBuffer = useMemoryMapped; |
| | | streamLogger.open(); |
| | |
| | | init(strict); |
| | | } |
| | | |
| | | public Dgn7fileReader(ReadableByteChannel channel, Lock lock) throws IOException, Dgn7fileException |
| | | { |
| | | public Dgn7fileReader(FileChannel channel, Lock lock) throws IOException, Dgn7fileException { |
| | | this(channel, true, true, lock); |
| | | } |
| | | |
| | | // ensure the capacity of the buffer is of size by doubling the original |
| | | // capacity until it is big enough |
| | | // this may be naiive and result in out of MemoryError as implemented... |
| | | public static ByteBuffer ensureCapacity(ByteBuffer buffer, int size, boolean useMemoryMappedBuffer) |
| | | { |
| | | public static ByteBuffer ensureCapacity(ByteBuffer buffer, int size, boolean useMemoryMappedBuffer) { |
| | | // This sucks if you accidentally pass is a MemoryMappedBuffer of size |
| | | // 80M |
| | | // like I did while messing around, within moments I had 1 gig of |
| | | // swap... |
| | | if (buffer.isReadOnly() || useMemoryMappedBuffer) |
| | | { |
| | | if (buffer.isReadOnly() || useMemoryMappedBuffer) { |
| | | return buffer; |
| | | } |
| | | |
| | | int limit = buffer.limit(); |
| | | |
| | | while (limit < size) |
| | | { |
| | | while (limit < size) { |
| | | limit *= 2; |
| | | } |
| | | |
| | | if (limit != buffer.limit()) |
| | | { |
| | | if (limit != buffer.limit()) { |
| | | // if (record.ready) { |
| | | buffer = ByteBuffer.allocateDirect(limit); |
| | | |
| | |
| | | } |
| | | |
| | | // for filling a ReadableByteChannel |
| | | public static int fill(ByteBuffer buffer, ReadableByteChannel channel) throws IOException |
| | | { |
| | | public static int fill(ByteBuffer buffer, ReadableByteChannel channel) throws IOException { |
| | | int r = buffer.remaining(); |
| | | |
| | | // channel reads return -1 when EOF or other error |
| | | // because they a non-blocking reads, 0 is a valid return value!! |
| | | while ((buffer.remaining() > 0) && (r != -1)) |
| | | { |
| | | while ((buffer.remaining() > 0) && (r != -1)) { |
| | | r = channel.read(buffer); |
| | | } |
| | | |
| | | if (r == -1) |
| | | { |
| | | if (r == -1) { |
| | | buffer.limit(buffer.position()); |
| | | } |
| | | |
| | | return r; |
| | | } |
| | | |
| | | public static Dgn7fileHeader readHeader(ReadableByteChannel channel, boolean strict) throws IOException |
| | | { |
| | | public static Dgn7fileHeader readHeader(ReadableByteChannel channel, boolean strict) throws IOException { |
| | | ByteBuffer buffer = ByteBuffer.allocateDirect(4); |
| | | |
| | | if (fill(buffer, channel) == -1) |
| | | { |
| | | if (fill(buffer, channel) == -1) { |
| | | throw new EOFException("Premature end of header"); |
| | | } |
| | | |
| | |
| | | buffer = ByteBuffer.allocateDirect(length + 4); |
| | | buffer.put(old); |
| | | |
| | | if (fill(buffer, channel) == -1) |
| | | { |
| | | if (fill(buffer, channel) == -1) { |
| | | throw new EOFException("Premature end of header"); |
| | | } |
| | | |
| | |
| | | return header; |
| | | } |
| | | |
| | | public Dgn7fileHeader getHeader() |
| | | { |
| | | public Dgn7fileHeader getHeader() { |
| | | return header; |
| | | } |
| | | |
| | | public void close() throws IOException |
| | | { |
| | | public void close() throws IOException { |
| | | lock.unlockRead(); |
| | | |
| | | if (channel.isOpen()) |
| | | { |
| | | if (channel.isOpen()) { |
| | | channel.close(); |
| | | streamLogger.close(); |
| | | } |
| | | |
| | | if (buffer instanceof MappedByteBuffer) |
| | | { |
| | | if (buffer instanceof MappedByteBuffer) { |
| | | NIOUtilities.clean(buffer); |
| | | } |
| | | |
| | |
| | | header = null; |
| | | } |
| | | |
| | | public boolean supportsRandomAccess() |
| | | { |
| | | public boolean supportsRandomAccess() { |
| | | return randomAccessEnabled; |
| | | } |
| | | |
| | | public Record nextElement() throws IOException, Dgn7fileException |
| | | { |
| | | public Element.FileRecord nextElement() throws IOException, Dgn7fileException { |
| | | // need to update position |
| | | buffer.position(this.toBufferOffset(record.end)); |
| | | |
| | |
| | | // track the record location |
| | | int elementLength = (buffer.getShort() * 2) + 4; |
| | | |
| | | if (!buffer.isReadOnly() && !useMemoryMappedBuffer) |
| | | { |
| | | if (!buffer.isReadOnly() && !useMemoryMappedBuffer) { |
| | | // capacity is less than required for the record |
| | | // copy the old into the newly allocated |
| | | if (buffer.capacity() < elementLength) |
| | | { |
| | | if (buffer.capacity() < elementLength) { |
| | | this.currentOffset += buffer.position(); |
| | | |
| | | ByteBuffer old = buffer; |
| | |
| | | // remaining is less than record length |
| | | // compact the remaining data and read again, |
| | | // allowing enough room for one more record header |
| | | if (buffer.remaining() < elementLength) |
| | | { |
| | | if (buffer.remaining() < elementLength) { |
| | | this.currentOffset += buffer.position(); |
| | | buffer.compact(); |
| | | fill(buffer, channel); |
| | |
| | | // second guess them... |
| | | buffer.mark(); |
| | | |
| | | if (recordType.isMultiPoint()) |
| | | { |
| | | if (recordType.isMultiPoint()) { |
| | | int lowCoorX = buffer.getInt(); |
| | | |
| | | lowCoorX = DgnUtility.convertFromDGN(lowCoorX); |
| | |
| | | record.length = elementLength; |
| | | record.signature = signature; |
| | | record.number = recordNumber; |
| | | record.buffer = buffer; |
| | | |
| | | // remember, we read one int already... |
| | | record.end = this.toFileOffset(buffer.position()) + elementLength - 4; |
| | |
| | | return record; |
| | | } |
| | | |
| | | public void goTo(int offset) throws IOException, UnsupportedOperationException |
| | | { |
| | | if (randomAccessEnabled) |
| | | { |
| | | if (this.useMemoryMappedBuffer) |
| | | { |
| | | public void goTo(int offset) throws IOException, UnsupportedOperationException { |
| | | if (randomAccessEnabled) { |
| | | if (this.useMemoryMappedBuffer) { |
| | | buffer.position(offset); |
| | | } else |
| | | { |
| | | } else { |
| | | /* |
| | | * Check to see if requested offset is already loaded; ensure |
| | | * that record header is in the buffer |
| | | */ |
| | | if ((this.currentOffset <= offset) && (this.currentOffset + buffer.limit() >= offset + 4)) |
| | | { |
| | | if ((this.currentOffset <= offset) && (this.currentOffset + buffer.limit() >= offset + 4)) { |
| | | buffer.position(this.toBufferOffset(offset)); |
| | | } else |
| | | { |
| | | } else { |
| | | FileChannel fc = (FileChannel) this.channel; |
| | | |
| | | fc.position(offset); |
| | |
| | | |
| | | record.end = offset; |
| | | |
| | | try |
| | | { |
| | | try { |
| | | hasNext(); |
| | | } catch (IOException ioe) |
| | | { |
| | | } catch (IOException ioe) { |
| | | record.end = oldRecordOffset; |
| | | |
| | | throw ioe; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | throw new UnsupportedOperationException("Random Access not enabled"); |
| | | } |
| | | } |
| | | |
| | | public Record elementAt(int offset) throws IOException, UnsupportedOperationException, Dgn7fileException |
| | | { |
| | | if (randomAccessEnabled) |
| | | { |
| | | public Element.FileRecord elementAt(int offset) throws IOException, UnsupportedOperationException, Dgn7fileException { |
| | | if (randomAccessEnabled) { |
| | | this.goTo(offset); |
| | | |
| | | return nextElement(); |
| | |
| | | throw new UnsupportedOperationException("Random Access not enabled"); |
| | | } |
| | | |
| | | public boolean hasNext() throws IOException |
| | | { |
| | | public boolean hasNext() throws IOException { |
| | | // mark current position |
| | | int position = buffer.position(); |
| | | |
| | | // ensure the proper position, regardless of read or handler behavior |
| | | try |
| | | { |
| | | try { |
| | | buffer.position(this.toBufferOffset(record.end)); |
| | | } catch (IllegalArgumentException e) |
| | | { |
| | | } catch (IllegalArgumentException e) { |
| | | logger.warn("position=" + this.toBufferOffset(record.end), e); |
| | | |
| | | return false; |
| | | } |
| | | |
| | | // no more data left |
| | | if (buffer.remaining() < 4) |
| | | { |
| | | if (buffer.remaining() < 4) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | boolean hasNext = true; |
| | | short type = buffer.getShort(); |
| | | |
| | | if (type == -1) |
| | | { |
| | | if (type == -1) { |
| | | hasNext = false; |
| | | } |
| | | |
| | |
| | | return hasNext; |
| | | } |
| | | |
| | | private void init(boolean strict) throws IOException, Dgn7fileException |
| | | { |
| | | private void init(boolean strict) throws IOException, Dgn7fileException { |
| | | header = readHeader(channel, strict); |
| | | |
| | | // fileElementType = header.getElementType(); |
| | |
| | | // { |
| | | // throw new IOException("Unsuported shape type:" + fileElementType); |
| | | // } |
| | | if ((channel instanceof FileChannel) && useMemoryMappedBuffer) |
| | | { |
| | | if ((channel instanceof FileChannel) && useMemoryMappedBuffer) { |
| | | FileChannel fc = (FileChannel) channel; |
| | | |
| | | buffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); |
| | |
| | | // buffer.position(100); |
| | | buffer.position(header.size()); |
| | | this.currentOffset = 0; |
| | | } else |
| | | { |
| | | } else { |
| | | // force useMemoryMappedBuffer to false |
| | | this.useMemoryMappedBuffer = false; |
| | | |
| | |
| | | record.end = toFileOffset(buffer.position()); |
| | | } |
| | | |
| | | private int toBufferOffset(int offset) |
| | | { |
| | | private int toBufferOffset(int offset) { |
| | | return (int) (offset - currentOffset); |
| | | } |
| | | |
| | | private int toFileOffset(int offset) |
| | | { |
| | | private int toFileOffset(int offset) { |
| | | return (int) (currentOffset + offset); |
| | | } |
| | | |
| | | public int getCount(int count) throws Dgn7fileException |
| | | { |
| | | try |
| | | { |
| | | if (channel == null) |
| | | { |
| | | public int getCount(int count) throws Dgn7fileException { |
| | | try { |
| | | if (channel == null) { |
| | | return -1; |
| | | } |
| | | |
| | | count = 0; |
| | | |
| | | for (int tmp = readElement(); tmp != -1; tmp = readElement()) |
| | | { |
| | | for (int tmp = readElement(); tmp != -1; tmp = readElement()) { |
| | | count += tmp; |
| | | } |
| | | } catch (IOException ioe) |
| | | { |
| | | } catch (IOException ioe) { |
| | | count = -1; |
| | | |
| | | // What now? This seems arbitrarily appropriate ! |
| | |
| | | return count; |
| | | } |
| | | |
| | | public int getCount() throws Dgn7fileException |
| | | { |
| | | public int getCount() throws Dgn7fileException { |
| | | return getCount(0); |
| | | } |
| | | |
| | | private int readElement() throws IOException |
| | | { |
| | | if (!fillBuffer()) |
| | | { |
| | | private int readElement() throws IOException { |
| | | if (!fillBuffer()) { |
| | | return -1; |
| | | } |
| | | |
| | | // burn the record number |
| | | buffer.getInt(); |
| | | |
| | | if (!fillBuffer()) |
| | | { |
| | | if (!fillBuffer()) { |
| | | return -1; |
| | | } |
| | | |
| | |
| | | // subtract that from the record length |
| | | recordlength -= 4; |
| | | |
| | | if (!fillBuffer()) |
| | | { |
| | | if (!fillBuffer()) { |
| | | return -1; |
| | | } |
| | | |
| | |
| | | int type = buffer.getInt(); |
| | | |
| | | // go to end of record |
| | | while (buffer.limit() < buffer.position() + recordlength) |
| | | { |
| | | while (buffer.limit() < buffer.position() + recordlength) { |
| | | recordlength -= buffer.limit() - buffer.position(); |
| | | buffer.clear(); |
| | | |
| | | if (channel.read(buffer) < 1) |
| | | { |
| | | if (channel.read(buffer) < 1) { |
| | | return -1; |
| | | } |
| | | } |
| | |
| | | buffer.position(buffer.position() + recordlength); |
| | | |
| | | // return 0 if record is null. Null records should be counted. |
| | | if (type == 0) |
| | | { |
| | | if (type == 0) { |
| | | // this is a null feature |
| | | return 0; |
| | | } |
| | |
| | | return 1; |
| | | } |
| | | |
| | | private boolean fillBuffer() throws IOException |
| | | { |
| | | private boolean fillBuffer() throws IOException { |
| | | int result = 1; |
| | | |
| | | if (buffer.limit() <= buffer.position() + 4) |
| | | { |
| | | if (buffer.limit() <= buffer.position() + 4) { |
| | | result = fill(buffer, channel); |
| | | } |
| | | |
| | | return result > 0; |
| | | } |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | public static void main(String[] args) { |
| | | JFileChooser jfc = new JFileChooser("D:/TEMP"); |
| | | File f = null; |
| | | int r = jfc.showOpenDialog(new JFrame()); |
| | | |
| | | if (r == JFileChooser.APPROVE_OPTION) |
| | | { |
| | | try |
| | | { |
| | | if (r == JFileChooser.APPROVE_OPTION) { |
| | | try { |
| | | f = jfc.getSelectedFile(); |
| | | |
| | | FileChannel channel = new FileInputStream(f).getChannel(); |
| | |
| | | count = 0; |
| | | size = 0; |
| | | |
| | | try |
| | | { |
| | | try { |
| | | Element lastComplex = null; |
| | | |
| | | while (reader.hasNext()) |
| | | { |
| | | while (reader.hasNext()) { |
| | | size++; |
| | | |
| | | Dgn7fileReader.Record record = reader.nextElement(); |
| | | Element.FileRecord record = reader.nextElement(); |
| | | |
| | | if (record.element() != null) |
| | | { |
| | | if (record.element() != null) { |
| | | Element element = (Element) record.element(); |
| | | ElementType type = element.getElementType(); |
| | | |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) { |
| | | if (lastComplex != null) { |
| | | // @todo add process in here |
| | | count++; |
| | | lastComplex = null; |
| | |
| | | |
| | | // @todo add process in here |
| | | count++; |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | } else if (element.isComponentElement()) { |
| | | if (lastComplex != null) { |
| | | ((ComplexElement) lastComplex).add(element); |
| | | } |
| | | } else if (type.isComplexElement()) |
| | | { |
| | | if (lastComplex == null) |
| | | { |
| | | } else if (type.isComplexElement()) { |
| | | if (lastComplex == null) { |
| | | lastComplex = element; |
| | | } else |
| | | { |
| | | } else { |
| | | // @todo add process in here |
| | | count++; |
| | | lastComplex = element; |
| | |
| | | } |
| | | } |
| | | } |
| | | } catch (IOException e) |
| | | { |
| | | } catch (IOException e) { |
| | | logger.warn("Stop read dgn file", e); |
| | | } catch (Dgn7fileException e) |
| | | { |
| | | e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. |
| | | } finally |
| | | { |
| | | } catch (Dgn7fileException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | |
| | | System.out.println("count=" + count + " size=" + size); |
| | | logger.debug("count=" + count + " size=" + size); |
| | | // reader.close(); |
| | | } catch (IOException ioe) |
| | | { |
| | | System.out.println(ioe); |
| | | ioe.printStackTrace(); |
| | | } catch (Dgn7fileException e) |
| | | { |
| | | e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. |
| | | } catch (IOException ioe) { |
| | | logger.warn(ioe.getMessage(), ioe); |
| | | } catch (Dgn7fileException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | System.exit(0); |
| | | } |
| | | |
| | | public final class Record |
| | | { |
| | | int length; |
| | | int number = 0; |
| | | int offset; // Relative to the whole file |
| | | int start = 0; // Relative to the current loaded buffer |
| | | short signature = 0; |
| | | |
| | | /** |
| | | * The minimum X value. |
| | | */ |
| | | public double minX; |
| | | |
| | | /** |
| | | * The minimum Y value. |
| | | */ |
| | | public double minY; |
| | | |
| | | /** |
| | | * The minimum Z value. |
| | | */ |
| | | public double minZ; |
| | | |
| | | /** |
| | | * The maximum X value. |
| | | */ |
| | | public double maxX; |
| | | |
| | | /** |
| | | * The maximum Y value. |
| | | */ |
| | | public double maxY; |
| | | |
| | | /** |
| | | * The maximum Z value. |
| | | */ |
| | | public double maxZ; |
| | | |
| | | // ElementType type; |
| | | int end = 0; // Relative to the whole file |
| | | Object element = null; |
| | | IElementHandler handler; |
| | | |
| | | public Object element() |
| | | { |
| | | if (element == null) |
| | | { |
| | | buffer.position(start); |
| | | buffer.order(ByteOrder.LITTLE_ENDIAN); |
| | | |
| | | if (handler == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | element = handler.read(buffer, signature, length); |
| | | } |
| | | |
| | | return element; |
| | | } |
| | | |
| | | public int offset() |
| | | { |
| | | return offset; |
| | | } |
| | | |
| | | /** |
| | | * A summary of the record. |
| | | */ |
| | | public String toString() |
| | | { |
| | | return "Record " + number + " length " + length + " bounds " + minX + "," + minY + " " + maxX + "," + maxY; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ximple.io.dgn7;
|
| | |
|
| | | import com.ximple.util.DgnUtility;
|
| | | import org.apache.log4j.LogManager;
|
| | | import org.apache.log4j.Logger;
|
| | |
|
| | | import java.io.EOFException;
|
| | | import java.io.IOException;
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | | import java.nio.MappedByteBuffer;
|
| | | import java.nio.ShortBuffer;
|
| | | import java.nio.channels.FileChannel;
|
| | | import java.nio.channels.ReadableByteChannel;
|
| | | import java.nio.channels.WritableByteChannel;
|
| | |
|
| | | public class Dgn7fileWriter {
|
| | | private static final Logger logger = LogManager.getLogger(Dgn7fileWriter.class);
|
| | |
|
| | | private Dgn7fileHeader header;
|
| | | private FileChannel channel;
|
| | | ByteBuffer buffer;
|
| | | private ElementType fileElementType = ElementType.UNDEFINED;
|
| | | private ByteBuffer headerTransfer;
|
| | | private final Element.FileRecord record = new Element.FileRecord();
|
| | | private final boolean randomAccessEnabled;
|
| | | private Lock lock;
|
| | | private boolean useMemoryMappedBuffer;
|
| | | private long currentOffset = 0L;
|
| | | private StreamLogging streamLogger = new StreamLogging("Dgn7 Writer");
|
| | | private int maxElementId = 0;
|
| | |
|
| | | public Dgn7fileWriter(FileChannel channel, boolean strict, boolean useMemoryMapped, Lock lock)
|
| | | throws IOException, Dgn7fileException {
|
| | | this.channel = channel;
|
| | | this.useMemoryMappedBuffer = useMemoryMapped;
|
| | | streamLogger.open();
|
| | | randomAccessEnabled = channel instanceof FileChannel;
|
| | | this.lock = lock;
|
| | | lock.lockRead();
|
| | | lock.lockWrite();
|
| | | // init(strict);
|
| | | }
|
| | |
|
| | | public Dgn7fileWriter(FileChannel channel, Lock lock) throws IOException, Dgn7fileException {
|
| | | this(channel, true, true, lock);
|
| | | }
|
| | |
|
| | | protected boolean hasNext() throws IOException {
|
| | | // mark current position
|
| | | int position = buffer.position();
|
| | |
|
| | | // ensure the proper position, regardless of read or handler behavior
|
| | | try {
|
| | | buffer.position(this.toBufferOffset(record.end));
|
| | | } catch (IllegalArgumentException e) {
|
| | | logger.warn("position=" + this.toBufferOffset(record.end), e);
|
| | |
|
| | | return false;
|
| | | }
|
| | |
|
| | | // no more data left
|
| | | if (buffer.remaining() < 4) {
|
| | | return false;
|
| | | }
|
| | |
|
| | | // looks good
|
| | | boolean hasNext = true;
|
| | | short type = buffer.getShort();
|
| | |
|
| | | if (type == -1) {
|
| | | hasNext = false;
|
| | | }
|
| | |
|
| | | // reset things to as they were
|
| | | buffer.position(position);
|
| | |
|
| | | return hasNext;
|
| | | }
|
| | |
|
| | | protected Element.FileRecord nextElement() throws IOException, Dgn7fileException {
|
| | | // need to update position
|
| | | buffer.position(this.toBufferOffset(record.end));
|
| | |
|
| | | // record header is big endian
|
| | | buffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | |
|
| | | // read shape record header
|
| | | int recordNumber = ++maxElementId;
|
| | | short signature = buffer.getShort();
|
| | |
|
| | | // byte type = (byte) (buffer.get() & 0x7f);
|
| | | byte type = (byte) ((signature >>> 8) & 0x007f);
|
| | |
|
| | | // silly Bentley say contentLength is in 2-byte words
|
| | | // and ByteByffer uses bytes.
|
| | | // track the record location
|
| | | int elementLength = (buffer.getShort() * 2) + 4;
|
| | |
|
| | | if (!buffer.isReadOnly() && !useMemoryMappedBuffer) {
|
| | | // capacity is less than required for the record
|
| | | // copy the old into the newly allocated
|
| | | if (buffer.capacity() < elementLength) {
|
| | | this.currentOffset += buffer.position();
|
| | |
|
| | | ByteBuffer old = buffer;
|
| | |
|
| | | // ensure enough capacity for one more record header
|
| | | buffer = Dgn7fileReader.ensureCapacity(buffer, elementLength, useMemoryMappedBuffer);
|
| | | buffer.put(old);
|
| | | fill(buffer, channel);
|
| | | buffer.position(0);
|
| | | } else
|
| | |
|
| | | // remaining is less than record length
|
| | | // compact the remaining data and read again,
|
| | | // allowing enough room for one more record header
|
| | | if (buffer.remaining() < elementLength) {
|
| | | this.currentOffset += buffer.position();
|
| | | buffer.compact();
|
| | | fill(buffer, channel);
|
| | | buffer.position(0);
|
| | | }
|
| | | }
|
| | |
|
| | | // shape record is all little endian
|
| | | // buffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | // read the type, handlers don't need it
|
| | | ElementType recordType = ElementType.forID(type);
|
| | |
|
| | | logger.debug("nextElement at " + this.toBufferOffset(record.end) + ":type=" + type);
|
| | |
|
| | | // this usually happens if the handler logic is bunk,
|
| | | // but bad files could exist as well...
|
| | |
|
| | | /*
|
| | | * if (recordType != ElementType.NULL && recordType != fileElementType)
|
| | | * {
|
| | | * throw new IllegalStateException("ShapeType changed illegally from " + fileElementType + " to " + recordType);
|
| | | * }
|
| | | */
|
| | |
|
| | | // peek at bounds, then reset for handler
|
| | | // many handler's may ignore bounds reading, but we don't want to
|
| | | // second guess them...
|
| | | buffer.mark();
|
| | |
|
| | | if (recordType.isMultiPoint()) {
|
| | | int lowCoorX = buffer.getInt();
|
| | |
|
| | | lowCoorX = DgnUtility.convertFromDGN(lowCoorX);
|
| | | record.minX = DgnUtility.converUnitToCoord(lowCoorX);
|
| | |
|
| | | int lowCoorY = buffer.getInt();
|
| | |
|
| | | lowCoorY = DgnUtility.convertFromDGN(lowCoorY);
|
| | | record.minY = DgnUtility.converUnitToCoord(lowCoorY);
|
| | |
|
| | | int lowCoorZ = buffer.getInt();
|
| | |
|
| | | lowCoorZ = DgnUtility.convertFromDGN(lowCoorZ);
|
| | | record.minZ = DgnUtility.converUnitToCoord(lowCoorZ);
|
| | |
|
| | | int highCoorX = buffer.getInt();
|
| | |
|
| | | highCoorX = DgnUtility.convertFromDGN(highCoorX);
|
| | | record.maxX = DgnUtility.converUnitToCoord(highCoorX);
|
| | |
|
| | | int highCoorY = buffer.getInt();
|
| | |
|
| | | highCoorY = DgnUtility.convertFromDGN(highCoorY);
|
| | | record.maxY = DgnUtility.converUnitToCoord(highCoorY);
|
| | |
|
| | | int highCoorZ = buffer.getInt();
|
| | |
|
| | | highCoorZ = DgnUtility.convertFromDGN(highCoorZ);
|
| | | record.maxZ = DgnUtility.converUnitToCoord(highCoorZ);
|
| | | }
|
| | |
|
| | | buffer.reset();
|
| | | record.offset = record.end;
|
| | |
|
| | | // update all the record info.
|
| | | record.length = elementLength;
|
| | | record.signature = signature;
|
| | | record.number = recordNumber;
|
| | | record.buffer = buffer;
|
| | |
|
| | | // remember, we read one int already...
|
| | | record.end = this.toFileOffset(buffer.position()) + elementLength - 4;
|
| | | // record.end = this.toFileOffset(buffer.position()) + elementLength;
|
| | |
|
| | | // mark this position for the reader
|
| | | record.start = buffer.position();
|
| | |
|
| | | // clear any cached record
|
| | | record.handler = recordType.getElementHandler();
|
| | | record.element = null;
|
| | |
|
| | | return record;
|
| | | }
|
| | |
|
| | | private void init(boolean strict) throws IOException, Dgn7fileException {
|
| | | header = readHeader(channel, strict);
|
| | |
|
| | | if (useMemoryMappedBuffer) {
|
| | | FileChannel fc = channel;
|
| | |
|
| | | buffer = fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size());
|
| | |
|
| | | // buffer.position(100);
|
| | | buffer.position(header.size());
|
| | | this.currentOffset = 0;
|
| | | } else {
|
| | | // force useMemoryMappedBuffer to false
|
| | | this.useMemoryMappedBuffer = false;
|
| | |
|
| | | // start with 8K buffer
|
| | | buffer = ByteBuffer.allocateDirect(8 * 1024);
|
| | | fill(buffer, channel);
|
| | | buffer.flip();
|
| | | this.currentOffset = header.size();
|
| | | }
|
| | |
|
| | | headerTransfer = ByteBuffer.allocate(4);
|
| | | headerTransfer.order(ByteOrder.LITTLE_ENDIAN);
|
| | |
|
| | | // make sure the record end is set now...
|
| | | record.end = toFileOffset(buffer.position());
|
| | | }
|
| | |
|
| | | public static Dgn7fileHeader readHeader(FileChannel channel, boolean strict) throws IOException {
|
| | | ByteBuffer buffer = ByteBuffer.allocateDirect(4);
|
| | |
|
| | | if (fill(buffer, channel) == -1) {
|
| | | throw new EOFException("Premature end of header");
|
| | | }
|
| | |
|
| | | buffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | |
|
| | | int length = buffer.getShort(2) * 2;
|
| | | ByteBuffer old = buffer;
|
| | |
|
| | | old.position(0);
|
| | |
|
| | | // ensure enough capacity for one more record header
|
| | | buffer = ByteBuffer.allocateDirect(length + 4);
|
| | | buffer.put(old);
|
| | |
|
| | | if (fill(buffer, channel) == -1) {
|
| | | throw new EOFException("Premature end of header");
|
| | | }
|
| | |
|
| | | buffer.position(0);
|
| | |
|
| | | Dgn7fileHeader header = new Dgn7fileHeader();
|
| | |
|
| | | header.read(buffer, strict);
|
| | |
|
| | | return header;
|
| | | }
|
| | |
|
| | | protected static int fill(ByteBuffer buffer, FileChannel channel) throws IOException {
|
| | | int r = buffer.remaining();
|
| | |
|
| | | // channel reads return -1 when EOF or other error
|
| | | // because they a non-blocking reads, 0 is a valid return value!!
|
| | | while ((buffer.remaining() > 0) && (r != -1)) {
|
| | | r = channel.read(buffer);
|
| | | }
|
| | |
|
| | | if (r == -1) {
|
| | | buffer.limit(buffer.position());
|
| | | }
|
| | |
|
| | | return r;
|
| | | }
|
| | |
|
| | | private void allocateBuffers() {
|
| | | buffer = ByteBuffer.allocateDirect(16 * 1024);
|
| | | }
|
| | |
|
| | | private void checkShapeBuffer(int size) {
|
| | | if (buffer.capacity() < size) {
|
| | | if (buffer != null)
|
| | | NIOUtilities.clean(buffer);
|
| | | buffer = ByteBuffer.allocateDirect(size);
|
| | | }
|
| | | }
|
| | |
|
| | | private void drain() throws IOException {
|
| | | buffer.flip();
|
| | | while (buffer.remaining() > 0)
|
| | | channel.write(buffer);
|
| | | buffer.flip().limit(buffer.capacity());
|
| | | }
|
| | |
|
| | | private int toBufferOffset(int offset) {
|
| | | return (int) (offset - currentOffset);
|
| | | }
|
| | |
|
| | | private int toFileOffset(int offset) {
|
| | | return (int) (currentOffset + offset);
|
| | | }
|
| | |
|
| | | public void writeElement(Element element) throws IOException {
|
| | | if (element == null) return;
|
| | | if (element.getElementType().isComplexElement()) {
|
| | | writeTo(element);
|
| | | ComplexElement complexElement = (ComplexElement) element;
|
| | | for (Element component : complexElement) {
|
| | | writeTo(component);
|
| | | }
|
| | | } else {
|
| | | writeTo(element);
|
| | | }
|
| | | }
|
| | |
|
| | | private void writeTo(Element element) throws IOException {
|
| | | ByteBuffer writeBuffer = ByteBuffer.allocateDirect(element.raw.length * 2);
|
| | | writeBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | for (short word : element.raw) {
|
| | | writeBuffer.putShort(word);
|
| | | }
|
| | | writeBuffer.rewind();
|
| | |
|
| | | channel.write(writeBuffer);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public void toEnd() throws IOException, Dgn7fileException {
|
| | | while (hasNext()) {
|
| | | nextElement();
|
| | | }
|
| | | }
|
| | |
|
| | | public void close() throws IOException {
|
| | | lock.unlockWrite();
|
| | | lock.unlockRead();
|
| | |
|
| | | if (channel.isOpen()) {
|
| | | channel.close();
|
| | | streamLogger.close();
|
| | | }
|
| | |
|
| | | if (buffer instanceof MappedByteBuffer) {
|
| | | NIOUtilities.clean(buffer);
|
| | | }
|
| | |
|
| | | channel = null;
|
| | | header = null;
|
| | | }
|
| | |
|
| | | public void writeEOF() throws IOException {
|
| | | ByteBuffer writeBuffer = ByteBuffer.allocateDirect(2);
|
| | | writeBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | writeBuffer.putShort((short) -1);
|
| | | channel.write(writeBuffer);
|
| | |
|
| | | }
|
| | | }
|
| | |
| | | import java.nio.BufferUnderflowException; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.nio.ShortBuffer; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | import com.ximple.util.DgnUtility; |
| | | |
| | | /** |
| | | * Record |
| | | * FileRecord |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤W¤È 11:14:50 |
| | | */ |
| | | public class Element |
| | | { |
| | | public class Element { |
| | | public static final int CONSTRUCTION_CLASS = 0; |
| | | public static final int CONSTRUCTION_RULE_CLASS = 0; |
| | | public static final int DIMENSION_CLASS = 0; |
| | |
| | | protected short[] raw; |
| | | protected byte attrOffset = 0; |
| | | protected ByteBuffer rawBuffer; |
| | | protected boolean newElement = false; |
| | | |
| | | public Element(byte[] raw) |
| | | { |
| | | Element(byte[] raw) { |
| | | // this.raw = raw; |
| | | this.raw = new short[raw.length / 2]; |
| | | rawBuffer = ByteBuffer.wrap(raw); |
| | |
| | | rawBuffer.asShortBuffer().get(this.raw); |
| | | } |
| | | |
| | | public int getLineStyle() |
| | | { |
| | | public int getLineStyle() { |
| | | return (raw[17] & 0x0007); |
| | | } |
| | | |
| | | public Envelope getRange() |
| | | { |
| | | protected void setLineStyle(int value) { |
| | | if (value > -1 && value < 8) |
| | | raw[17] = (short) ((raw[17] & 0xfff8) | (value & 0x0007)); |
| | | else |
| | | new IllegalArgumentException("Out of Range!"); |
| | | } |
| | | |
| | | public Envelope getRange() { |
| | | int lowCoorX = ((raw[3] << 16) & 0xffff0000) + (raw[2] & 0x0000ffff); |
| | | lowCoorX = DgnUtility.convertFromDGN(lowCoorX); |
| | | |
| | |
| | | DgnUtility.converUnitToCoord(lowCoorY), DgnUtility.converUnitToCoord(highCoorY)); |
| | | } |
| | | |
| | | public void setRange(Envelope bbox) |
| | | { |
| | | public void setRange(Envelope bbox) { |
| | | int lowCoordX = DgnUtility.converCoordToUnit(bbox.getMinX()); |
| | | int temp = DgnUtility.converToDGN(lowCoordX); |
| | | raw[3] = (short) (temp >> 16 & 0x0000ffff); |
| | |
| | | raw[5] = (short) (temp >> 16 & 0x0000ffff); |
| | | raw[4] = (short) (temp & 0x0000ffff); |
| | | |
| | | // lowZ |
| | | raw[7] = 0; |
| | | raw[8] = 0; |
| | | |
| | | int highCoorX = DgnUtility.converCoordToUnit(bbox.getMaxX()); |
| | | temp = DgnUtility.converToDGN(highCoorX); |
| | | raw[9] = (short) (temp >> 16 & 0x0000ffff); |
| | |
| | | temp = DgnUtility.converToDGN(highCoorY); |
| | | raw[11] = (short) (temp >> 16 & 0x0000ffff); |
| | | raw[10] = (short) (temp & 0x0000ffff); |
| | | |
| | | // highZ |
| | | raw[13] = (short) 0xffff; |
| | | raw[12] = (short) 0xffff; |
| | | |
| | | } |
| | | |
| | | public boolean isComponentElement() |
| | | { |
| | | public boolean isComponentElement() { |
| | | return (short) ((raw[0] >>> 7) & 0x0001) == 1; |
| | | } |
| | | |
| | | public boolean removeUserAttributeData(int iLinkageId) |
| | | { |
| | | protected void setComponentElement(boolean value) { |
| | | raw[0] = (short) ((raw[0] & 0xff7f) | (value ? 0x0080 : 0x0)); |
| | | } |
| | | |
| | | public boolean removeUserAttributeData(int iLinkageId) { |
| | | return true; |
| | | } |
| | | |
| | | public boolean removeUserAttributeData(int iLinkageId, int iLinkageIndex) |
| | | { |
| | | public boolean removeUserAttributeData(int iLinkageId, int iLinkageIndex) { |
| | | return true; |
| | | } |
| | | |
| | | public boolean isDeleted() |
| | | { |
| | | public boolean isDeleted() { |
| | | return (short) ((raw[0] >>> 15) & 0x0001) == 1; |
| | | } |
| | | |
| | | public int getColorIndex() |
| | | { |
| | | protected void setDeleted(boolean value) { |
| | | raw[0] = (short) ((raw[0] & 0x7fff) | ((((value) ? 1 : 0) << 15) & 0x8000)); |
| | | } |
| | | |
| | | public int getColorIndex() { |
| | | return ((raw[17] >>> 8) & 0x00ff); |
| | | } |
| | | |
| | | public int getType() |
| | | protected void setColorIndex(int value) { |
| | | if (value > -1 && value < 256) |
| | | { |
| | | raw[17] = (short) ((raw[17] & 0x00ff) | (value << 8 & 0xff00)); |
| | | } else new IllegalArgumentException("Out of Range!"); |
| | | } |
| | | |
| | | public int getType() { |
| | | return ((raw[0] >>> 8) & 0x007f); |
| | | } |
| | | |
| | | public ElementType getElementType() |
| | | { |
| | | protected void setType(int value) { |
| | | raw[0] = (short) ((raw[0] & 0x80ff) | (value << 8) & 0x3f00); |
| | | } |
| | | |
| | | public ElementType getElementType() { |
| | | return ElementType.forID(getType()); |
| | | } |
| | | |
| | | public int getLevelIndex() |
| | | { |
| | | public int getLevelIndex() { |
| | | return (raw[0] & 0x003f); |
| | | } |
| | | |
| | | public void setLevelIndex(int value) |
| | | { |
| | | public void setLevelIndex(int value) { |
| | | raw[0] = (short) ((raw[0] & 0xffc0) | (value & 0x003f)); |
| | | } |
| | | |
| | | public int getWeight() |
| | | { |
| | | public int getWeight() { |
| | | return ((raw[17] >>> 3) & 0x001f); |
| | | } |
| | | |
| | | public void setWeight(int value) |
| | | { |
| | | if (value > -1 && value < 31) |
| | | { |
| | | public void setWeight(int value) { |
| | | if (value > -1 && value < 31) { |
| | | raw[17] = (short) ((raw[17] & 0xff07) | (value << 3 & 0x00f8)); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | throw new RuntimeException("Out of Range!"); |
| | | } |
| | | } |
| | | |
| | | public void addUserAttributeData(byte[] pDataBlock, Class dataClass, int iLinkageId) throws Element.Exception |
| | | { |
| | | public short getFollowLength() { |
| | | return raw[1]; |
| | | } |
| | | |
| | | public void addUserAttributeData(byte[] pDataBlock, int iLinkageId, Object oDataDef) throws Element.Exception |
| | | { |
| | | protected void setFollowLength(short value) { |
| | | assert (raw.length >= value + 2); |
| | | raw[1] = value; |
| | | } |
| | | |
| | | public boolean hasUserAttributeData() |
| | | { |
| | | if (raw[15] <= 0) |
| | | { |
| | | public void addUserAttributeData(byte[] pDataBlock, Class dataClass, int iLinkageId) throws Element.Exception { |
| | | } |
| | | |
| | | public void addUserAttributeData(byte[] pDataBlock, int iLinkageId, Object oDataDef) throws Element.Exception { |
| | | } |
| | | |
| | | public boolean hasUserAttributeData() { |
| | | if (raw[15] <= 0) { |
| | | return false; |
| | | } |
| | | |
| | | short index = (short) (raw[15] + 16); |
| | | |
| | | if (index == -1) |
| | | { |
| | | if (index == -1) { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | public List<UserAttributeData> getUserAttributeData() |
| | | { |
| | | public int getUserAttributeDataOffset() { |
| | | return (raw[15] + 16); |
| | | } |
| | | |
| | | public List<UserAttributeData> getUserAttributeData() { |
| | | short[] data; |
| | | short length, nextAttribute; |
| | | |
| | | if (raw[15] <= 0) |
| | | { |
| | | if (raw[15] <= 0) { |
| | | return new ArrayList<UserAttributeData>(); |
| | | } |
| | | |
| | | short index = (short) (raw[15] + 16 + attrOffset); |
| | | |
| | | if (index == -1) |
| | | { |
| | | if (index == -1) { |
| | | return null; |
| | | } |
| | | |
| | | ArrayList<UserAttributeData> aLinkageSet = new ArrayList<UserAttributeData>(); |
| | | |
| | | while (index < raw.length) |
| | | while (index < raw.length) { |
| | | |
| | | |
| | | if (raw[index] == 0 || ((short) raw[index]) == 0x8000) |
| | | { |
| | | index += 4; |
| | | aLinkageSet.add(null); |
| | | continue; |
| | | } |
| | | |
| | | length = (short) (raw[index] & (short) 0x00ff); |
| | | |
| | | if (length == 0) |
| | | { |
| | | if (length == 0) { |
| | | break; |
| | | } |
| | | |
| | | if (length > raw.length - index - 1) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | nextAttribute = (short) (index + length + 1); |
| | | data = new short[length]; |
| | | System.arraycopy(raw, index + 1, data, 0, length); |
| | | |
| | | if (data[0] == (short) 0x0020) |
| | | { |
| | | if (data[0] == (short) 0x0020) { |
| | | aLinkageSet.add(new FrammeAttributeData(data)); |
| | | } else |
| | | { |
| | | } else { |
| | | aLinkageSet.add(new UserAttributeData(data)); |
| | | } |
| | | |
| | |
| | | return aLinkageSet; |
| | | } |
| | | |
| | | public void getUserAttributeData(byte[] pDataBlock, Class dataClass, int iLinkageId, int iLinkageIndex) |
| | | { |
| | | public void getUserAttributeData(byte[] pDataBlock, Class dataClass, int iLinkageId, int iLinkageIndex) { |
| | | } |
| | | |
| | | public void getUserAttributeData(byte[] pDataBlock, int iLinkageId, Object oDataDef) |
| | | { |
| | | public void getUserAttributeData(byte[] pDataBlock, int iLinkageId, Object oDataDef) { |
| | | } |
| | | |
| | | |
| | | public ByteBuffer getRawBuffer() |
| | | { |
| | | public ByteBuffer getRawBuffer() { |
| | | return rawBuffer.asReadOnlyBuffer(); |
| | | } |
| | | |
| | | public short[] getRawArray() |
| | | { |
| | | public short[] getRawArray() { |
| | | if (raw == null) return null; |
| | | short[] result = new short[raw.length]; |
| | | System.arraycopy(raw, 0, result, 0, raw.length); |
| | | return result; |
| | | } |
| | | |
| | | public static class Exception extends java.lang.Exception |
| | | { |
| | | public Exception() |
| | | { |
| | | public static class Exception extends java.lang.Exception { |
| | | public Exception() { |
| | | } |
| | | |
| | | // Constructs an Record.Exception with no detail message. |
| | | public Exception(String oStrMessage) |
| | | { |
| | | // Constructs an ElementRecord.Exception with no detail message. |
| | | public Exception(String oStrMessage) { |
| | | super(oStrMessage); |
| | | } |
| | | } |
| | | |
| | | protected static int getOffsetPosition(int offset) |
| | | { |
| | | protected static int getOffsetPosition(int offset) { |
| | | return offset * 2; |
| | | } |
| | | |
| | | public void resyncBuffer() |
| | | { |
| | | public void resyncBuffer() { |
| | | byte[] tempRaw = new byte[this.raw.length * 2]; |
| | | ByteBuffer tempBuffer = ByteBuffer.wrap(tempRaw); |
| | | tempBuffer.order(ByteOrder.LITTLE_ENDIAN); |
| | |
| | | rawBuffer.position(pos); |
| | | } |
| | | |
| | | public static class ElementHandler implements IElementHandler |
| | | { |
| | | public static class ElementHandler implements IElementHandler { |
| | | ElementType elementType; |
| | | |
| | | public ElementHandler(ElementType elementType) |
| | | { |
| | | public ElementHandler(ElementType elementType) { |
| | | this.elementType = elementType; |
| | | } |
| | | |
| | | public ElementType getElementType() |
| | | { |
| | | public ElementType getElementType() { |
| | | return elementType; |
| | | } |
| | | |
| | | public Object read(ByteBuffer buffer, short signature, int length) |
| | | { |
| | | public Element read(ByteBuffer buffer, short signature, int length) { |
| | | byte[] dst = new byte[length]; |
| | | try |
| | | { |
| | | try { |
| | | buffer.get(dst, 4, dst.length - 4); |
| | | } catch (BufferUnderflowException exception) |
| | | { |
| | | } catch (BufferUnderflowException exception) { |
| | | throw exception; |
| | | } |
| | | |
| | |
| | | return elm; |
| | | } |
| | | |
| | | public void write(ByteBuffer buffer, Object element) |
| | | { |
| | | public void write(ByteBuffer buffer, Object element) { |
| | | buffer.put(((Element) element).rawBuffer); |
| | | } |
| | | |
| | | public int getLength(Object element) |
| | | { |
| | | public int getLength(Object element) { |
| | | return ((Element) element).raw.length; |
| | | } |
| | | |
| | | public int getBufferLength(Object element) |
| | | { |
| | | public int getBufferLength(Object element) { |
| | | return ((Element) element).rawBuffer.limit(); |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new Element(raw); |
| | | } |
| | | } |
| | | |
| | | public static final class FileRecord { |
| | | int length; |
| | | int number = 0; |
| | | int offset; // Relative to the whole file |
| | | int start = 0; // Relative to the current loaded buffer |
| | | short signature = 0; |
| | | |
| | | /** |
| | | * The minimum X value. |
| | | */ |
| | | public double minX; |
| | | |
| | | /** |
| | | * The minimum Y value. |
| | | */ |
| | | public double minY; |
| | | |
| | | /** |
| | | * The minimum Z value. |
| | | */ |
| | | public double minZ; |
| | | |
| | | /** |
| | | * The maximum X value. |
| | | */ |
| | | public double maxX; |
| | | |
| | | /** |
| | | * The maximum Y value. |
| | | */ |
| | | public double maxY; |
| | | |
| | | /** |
| | | * The maximum Z value. |
| | | */ |
| | | public double maxZ; |
| | | |
| | | // ElementType type; |
| | | int end = 0; // Relative to the whole file |
| | | Object element = null; |
| | | IElementHandler handler; |
| | | ByteBuffer buffer; |
| | | |
| | | public Object element() { |
| | | if (element == null) { |
| | | buffer.position(start); |
| | | buffer.order(ByteOrder.LITTLE_ENDIAN); |
| | | |
| | | if (handler == null) { |
| | | return null; |
| | | } |
| | | |
| | | element = handler.read(buffer, signature, length); |
| | | } |
| | | |
| | | return element; |
| | | } |
| | | |
| | | public int offset() { |
| | | return offset; |
| | | } |
| | | |
| | | /** |
| | | * A summary of the record. |
| | | */ |
| | | public String toString() { |
| | | return "FileRecord " + number + " length " + length + " bounds " + minX + "," + minY + " " + maxX + "," + maxY; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ximple.io.dgn7;
|
| | |
|
| | | import com.vividsolutions.jts.geom.Coordinate;
|
| | | import com.vividsolutions.jts.geom.GeometryFactory;
|
| | | import com.vividsolutions.jts.geom.LineString;
|
| | | import com.vividsolutions.jts.geom.LinearRing;
|
| | |
|
| | | import java.util.Arrays;
|
| | | import java.util.LinkedList;
|
| | |
|
| | | public class ElementFactory {
|
| | | static final int DEFAULT_ELMHEAD_LENGTH = 28;
|
| | | static final int DEFAULT_DISPHEAD_LENGTH = 8;
|
| | | static final int MINIMAL_ELEMLENGTH = 18 * 2;
|
| | |
|
| | | static final int MAXINUM_LINESTRING_PTLEN = 100;
|
| | |
|
| | | private static ElementFactory elementFactory = new ElementFactory();
|
| | | private static GeometryFactory factory = new GeometryFactory();
|
| | |
|
| | | public static Element createLineString(LineString linestring) {
|
| | | Coordinate[] pts = linestring.getCoordinates();
|
| | | LineStringElement element = elementFactory.createLineStringElement(pts);
|
| | | element.setRange(linestring.getEnvelopeInternal());
|
| | | return element;
|
| | | }
|
| | |
|
| | | public static Element createShape(LinearRing ring) {
|
| | | Coordinate[] pts = ring.getCoordinates();
|
| | | int elmsize = MINIMAL_ELEMLENGTH + 2 + pts.length * 8;
|
| | | ShapeElement element = new ShapeElement(new byte[elmsize]);
|
| | | for (int i = 0; i < pts.length; i++) {
|
| | | element.setX(i, pts[i].x);
|
| | | element.setY(i, pts[i].y);
|
| | | }
|
| | | element.setVerticeSize(pts.length);
|
| | | element.setType(ElementType.SHAPE.id);
|
| | | element.setFollowLength((short) ((elmsize / 2) - 2));
|
| | | element.setRange(ring.getEnvelopeInternal());
|
| | | element.setLevelIndex(0);
|
| | | element.setColorIndex(0);
|
| | | element.setWeight(0);
|
| | | element.setLineStyle(0);
|
| | | return element;
|
| | | }
|
| | |
|
| | | private LineStringElement createLineStringElement(Coordinate[] pts) {
|
| | | int elmsize = MINIMAL_ELEMLENGTH + 2 + pts.length * 8;
|
| | | LineStringElement element = new LineStringElement(new byte[elmsize]);
|
| | | for (int i = 0; i < pts.length; i++) {
|
| | | element.setX(i, pts[i].x);
|
| | | element.setY(i, pts[i].y);
|
| | | }
|
| | | element.setVerticeSize(pts.length);
|
| | | element.setType(ElementType.LINESTRING.id);
|
| | | element.setFollowLength((short) ((elmsize / 2) - 2));
|
| | | element.setLevelIndex(0);
|
| | | element.setColorIndex(0);
|
| | | element.setWeight(0);
|
| | | element.setLineStyle(0);
|
| | | return element;
|
| | | }
|
| | |
|
| | | private ShapeElement createShapeElement(Coordinate[] pts) {
|
| | | int elmsize = MINIMAL_ELEMLENGTH + 2 + pts.length * 8;
|
| | | ShapeElement element = new ShapeElement(new byte[elmsize]);
|
| | | for (int i = 0; i < pts.length; i++) {
|
| | | element.setX(i, pts[i].x);
|
| | | element.setY(i, pts[i].y);
|
| | | }
|
| | | element.setVerticeSize(pts.length);
|
| | | element.setType(ElementType.SHAPE.id);
|
| | | element.setFollowLength((short) ((elmsize / 2) - 2));
|
| | | element.setLevelIndex(0);
|
| | | element.setColorIndex(0);
|
| | | element.setWeight(0);
|
| | | element.setLineStyle(0);
|
| | | return element;
|
| | | }
|
| | |
|
| | | public static Element createComplexChain(LineString linestring) {
|
| | | LinkedList<LineStringElement> elms = new LinkedList<LineStringElement>();
|
| | | Coordinate[] allpts = linestring.getCoordinates();
|
| | | int segsize = allpts.length / MAXINUM_LINESTRING_PTLEN;
|
| | | int currentpos = 0;
|
| | | int totalLength = 0;
|
| | | for (int seg = 0; seg < segsize; seg++) {
|
| | | Coordinate[] pts = Arrays.copyOfRange(allpts,
|
| | | currentpos, currentpos + MAXINUM_LINESTRING_PTLEN + 1, Coordinate[].class);
|
| | | LineStringElement element = elementFactory.createLineStringElement(pts);
|
| | | currentpos += MAXINUM_LINESTRING_PTLEN;
|
| | | element.setRange(element.toGeometry(factory).getEnvelopeInternal());
|
| | | element.setComponentElement(true);
|
| | | element.setLevelIndex(0);
|
| | | totalLength += element.raw.length;
|
| | | elms.add(element);
|
| | | }
|
| | | int remain = allpts.length % MAXINUM_LINESTRING_PTLEN;
|
| | | Coordinate[] pts = Arrays.copyOfRange(allpts,
|
| | | currentpos, currentpos + remain, Coordinate[].class);
|
| | | LineStringElement element = elementFactory.createLineStringElement(pts);
|
| | | element.setRange(element.toGeometry(factory).getEnvelopeInternal());
|
| | | element.setComponentElement(true);
|
| | | element.setLevelIndex(0);
|
| | | elms.add(element);
|
| | | totalLength += element.raw.length;
|
| | |
|
| | | ComplexChainElement result = new ComplexChainElement(new byte[MINIMAL_ELEMLENGTH + 12]);
|
| | | result.addAll(elms);
|
| | | result.setRange(linestring.getEnvelopeInternal());
|
| | | result.setType(ElementType.COMPLEXCHAIN.id);
|
| | | result.setFollowLength((short) (((MINIMAL_ELEMLENGTH + 12) / 2) - 2));
|
| | | result.setNumOfElement((short) elms.size());
|
| | | totalLength += result.raw.length;
|
| | | totalLength -= 19;
|
| | | result.setTotalLength((short) totalLength);
|
| | | result.setLevelIndex(0);
|
| | | result.setColorIndex(0);
|
| | | result.setWeight(0);
|
| | | result.setLineStyle(0);
|
| | |
|
| | | return result;
|
| | | }
|
| | | }
|
| | |
| | | | 23 Circular Truncated Cone | |
| | | | 24 B-Spline Surface (complex) | |
| | | | 25 B-Spline Surface boundary | |
| | | | 26 B-Spline Knot Record | |
| | | | 26 B-Spline Knot ElementRecord | |
| | | | 27 B-Spline Curve (complex) | |
| | | | 28 B-Spline Weight Factor | |
| | | | 33 Dimension Record | |
| | | | 34 Shared Cell Definition Record | |
| | | | 35 Shared Cell Record | |
| | | | 36 Multiline Record | |
| | | | 37 Attribute Record | |
| | | | 33 Dimension ElementRecord | |
| | | | 34 Shared Cell Definition ElementRecord | |
| | | | 35 Shared Cell ElementRecord | |
| | | | 36 Multiline ElementRecord | |
| | | | 37 Attribute ElementRecord | |
| | | | 38 DgnStore Component | |
| | | | 39 DgnStore Header | |
| | | | 66 MicroStation Application | |
| | |
| | | | 88 Raster Component | |
| | | | 90 Raster Reference Attachment | |
| | | | 91 Raster Reference Component | |
| | | | 92 Raster Hierarchy Record | |
| | | | 92 Raster Hierarchy ElementRecord | |
| | | | 93 Raster Hierarchy Component | |
| | | | 94 Raster Frame Record | |
| | | | 95 Table Entry Record | |
| | | | 96 Table Header Record | |
| | | | 97 View Group Record | |
| | | | 98 View Record | |
| | | | 99 Level Mask Record | |
| | | | 100 Reference Attach Record | |
| | | | 94 Raster Frame ElementRecord | |
| | | | 95 Table Entry ElementRecord | |
| | | | 96 Table Header ElementRecord | |
| | | | 97 View Group ElementRecord | |
| | | | 98 View ElementRecord | |
| | | | 99 Level Mask ElementRecord | |
| | | | 100 Reference Attach ElementRecord | |
| | | | 101 Matrix Header | |
| | | | 102 Matrix Int Data | |
| | | | 103 Matrix Double Data | |
| | | | 105 Mesh Header | |
| | | | 106 Extended Record (graphic) (complex) | |
| | | | 107 Extended Record (non-graphic) (complex) | |
| | | | 108 Reference Override Record | |
| | | | 106 Extended ElementRecord (graphic) (complex) | |
| | | | 107 Extended ElementRecord (non-graphic) (complex) | |
| | | | 108 Reference Override ElementRecord | |
| | | | 110 Named Group Header | |
| | | | 111 Named Group Component | |
| | | | | |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/17 ¤U¤È 01:26:49 |
| | | * @since 2006/5/17 �U�� 01:26:49 |
| | | */ |
| | | public final class ElementType |
| | | { |
| | | public final class ElementType { |
| | | /** |
| | | * Represents a Null shape (id = 0). |
| | | */ |
| | |
| | | * @param id The id. |
| | | * @param name The name. |
| | | */ |
| | | protected ElementType(int id, String name) |
| | | { |
| | | protected ElementType(int id, String name) { |
| | | this.id = id; |
| | | this.name = name; |
| | | } |
| | |
| | | * |
| | | * @return The name. |
| | | */ |
| | | public String toString() |
| | | { |
| | | public String toString() { |
| | | return name; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return true if multipoint, false otherwise. |
| | | */ |
| | | public boolean isMultiPoint() |
| | | { |
| | | public boolean isMultiPoint() { |
| | | boolean mp = true; |
| | | |
| | | if (this == UNDEFINED) |
| | | { |
| | | if (this == UNDEFINED) { |
| | | mp = false; |
| | | } else if (this == NULL) |
| | | { |
| | | } else if (this == NULL) { |
| | | mp = false; |
| | | } else if (this == IGDSDIGITIZER) |
| | | { |
| | | } else if (this == IGDSDIGITIZER) { |
| | | mp = false; |
| | | } else if (this == TCB) |
| | | { |
| | | } else if (this == TCB) { |
| | | mp = false; |
| | | } else if (this == LEVELSYMBOLOGY) |
| | | { |
| | | } else if (this == LEVELSYMBOLOGY) { |
| | | mp = false; |
| | | } |
| | | |
| | | return mp; |
| | | } |
| | | |
| | | public boolean isComplexElement() |
| | | { |
| | | public boolean isComplexElement() { |
| | | return id == 2 || id == 7 || id == 12 || id == 14 || id == 18 || |
| | | id == 19 || id == 106 || id == 107; |
| | | |
| | | } |
| | | |
| | | public boolean isPointType() |
| | | { |
| | | public boolean isPointType() { |
| | | return id == 7 || id == 17; |
| | | |
| | | } |
| | | |
| | | public boolean isLineType() |
| | | { |
| | | public boolean isLineType() { |
| | | return id == 3 || id == 4 || id == 11 || id == 12 || id == 16; |
| | | |
| | | } |
| | | |
| | | public boolean isPolygonType() |
| | | { |
| | | public boolean isPolygonType() { |
| | | return id == 6 || id == 14; |
| | | |
| | | } |
| | | |
| | | public boolean isMultiPointType() |
| | | { |
| | | public boolean isMultiPointType() { |
| | | return id == 3 || id == 4 || id == 6 || id == 11 || id == 12 || |
| | | id == 13 || id == 14 || id == 15 || id == 16 || id == 22; |
| | | |
| | | } |
| | | |
| | | public boolean isArcType() |
| | | { |
| | | public boolean isArcType() { |
| | | return id == 15 || (id == 16); |
| | | } |
| | | |
| | |
| | | * @param id The id to search for. |
| | | * @return The ElementType for the id. |
| | | */ |
| | | public static ElementType forID(int id) |
| | | { |
| | | public static ElementType forID(int id) { |
| | | ElementType t; |
| | | |
| | | switch (id) |
| | | { |
| | | switch (id) { |
| | | case 0: |
| | | t = NULL; |
| | | break; |
| | |
| | | return t; |
| | | } |
| | | |
| | | public IElementHandler getElementHandler() throws Dgn7fileException |
| | | { |
| | | public IElementHandler getElementHandler() throws Dgn7fileException { |
| | | IElementHandler handler; |
| | | |
| | | switch (id) |
| | | { |
| | | switch (id) { |
| | | case 3: |
| | | handler = LineElement.ElementHandler.getInstance(); |
| | | break; |
| | |
| | | |
| | | import com.ximple.util.DgnUtility; |
| | | |
| | | public class EllipseElement extends Element implements GeometryConverter |
| | | { |
| | | public class EllipseElement extends Element implements GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(EllipseElement.class); |
| | | |
| | | public EllipseElement(byte[] raw) |
| | | { |
| | | EllipseElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public double getStartAngle() |
| | | { |
| | | public double getStartAngle() { |
| | | return 0.0; |
| | | } |
| | | |
| | | public void setStartAngle(double value) |
| | | { |
| | | public void setStartAngle(double value) { |
| | | } |
| | | |
| | | public double getSweepAngle() |
| | | { |
| | | public double getSweepAngle() { |
| | | return 360.0; |
| | | } |
| | | |
| | | public void setSweepAngle(double value) |
| | | { |
| | | public void setSweepAngle(double value) { |
| | | } |
| | | |
| | | public double getPrimary() |
| | | { |
| | | public double getPrimary() { |
| | | rawBuffer.position(18 * 2); |
| | | ByteOrder bo = rawBuffer.order(); |
| | | rawBuffer.order(ByteOrder.BIG_ENDIAN); |
| | |
| | | return DgnUtility.convertDGNToIEEEDouble(primary) / 1000.0; |
| | | } |
| | | |
| | | public void setPrimary(double value) |
| | | { |
| | | public void setPrimary(double value) { |
| | | double temp = value * 1000.0; |
| | | short[] primary = DgnUtility.convertIEEEDoubleToDGN(temp); |
| | | |
| | | System.arraycopy(primary, 0, raw, 18, 4); |
| | | } |
| | | |
| | | public double getSecondary() |
| | | { |
| | | public double getSecondary() { |
| | | rawBuffer.position(22 * 2); |
| | | ByteOrder bo = rawBuffer.order(); |
| | | rawBuffer.order(ByteOrder.BIG_ENDIAN); |
| | |
| | | return DgnUtility.convertDGNToIEEEDouble(secondary) / 1000.0; |
| | | } |
| | | |
| | | public void setSecondary(double value) |
| | | { |
| | | public void setSecondary(double value) { |
| | | double temp = value * 1000.0; |
| | | short[] secondary = DgnUtility.convertIEEEDoubleToDGN(temp); |
| | | |
| | | System.arraycopy(secondary, 0, raw, 22, 4); |
| | | } |
| | | |
| | | public double getRotationAngle() |
| | | { |
| | | public double getRotationAngle() { |
| | | int rotation = (raw[26] << 16 & 0xffff0000); |
| | | rotation |= raw[27] & 0x0000ffff; |
| | | |
| | | return DgnUtility.converIntToRotation(rotation); |
| | | } |
| | | |
| | | public void setRotationAngle(double value) |
| | | { |
| | | public void setRotationAngle(double value) { |
| | | int angle = DgnUtility.converRotatioToInt(value); |
| | | |
| | | raw[26] = (short) (angle >> 16 & 0x0000ffff); |
| | | raw[27] = (short) (angle & 0x0000ffff); |
| | | } |
| | | |
| | | public Coordinate getOrigin() |
| | | { |
| | | public Coordinate getOrigin() { |
| | | rawBuffer.position(28 * 2); |
| | | ByteOrder bo = rawBuffer.order(); |
| | | rawBuffer.order(ByteOrder.BIG_ENDIAN); |
| | |
| | | return new Coordinate(dx, dy); |
| | | } |
| | | |
| | | public void setOrigin(Coordinate value) |
| | | { |
| | | public void setOrigin(Coordinate value) { |
| | | double temp = DgnUtility.converCoordToUnit(value.x); |
| | | short[] x = DgnUtility.convertIEEEDoubleToDGN(temp); |
| | | |
| | |
| | | System.arraycopy(y, 0, raw, 32, 4); |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | double temp = Math.abs(getStartAngle() - getSweepAngle()); |
| | | temp /= 4; |
| | | int pts = (temp < 3) ? 3 : (int) temp; |
| | | return factory.createPolygon(factory.createLinearRing(convertToLineString(pts)), null); |
| | | return factory.createPolygon(factory.createLinearRing(convertToPolygon(pts)), null); |
| | | } |
| | | |
| | | private Coordinate[] convertToLineString(int pts) |
| | | { |
| | | private Coordinate[] convertToPolygon(int pts) { |
| | | ArrayList<Coordinate> result = new ArrayList<Coordinate>(); |
| | | double beta = DgnUtility.converRotationToRadian(-getRotationAngle()); |
| | | double startAngle = getStartAngle(); |
| | |
| | | double endAngle = startAngle + sweepAngle; |
| | | double steps = sweepAngle / pts; |
| | | double current; |
| | | if (sweepAngle < 0) |
| | | { |
| | | for (current = startAngle; current > endAngle; current += steps) |
| | | { |
| | | Coordinate pt = computePointOnArcByAngle(beta, current); |
| | | //sweepAngle always 360 degree |
| | | for (current = startAngle; current < endAngle; current += steps) { |
| | | Coordinate pt = computePointOnEllipseByAngle(beta, current); |
| | | result.add(pt); |
| | | } |
| | | |
| | | } else |
| | | { |
| | | for (current = startAngle; current < endAngle; current += steps) |
| | | { |
| | | Coordinate pt = computePointOnArcByAngle(beta, current); |
| | | result.add(pt); |
| | | } |
| | | } |
| | | |
| | | Coordinate pt = computePointOnArcByAngle(beta, endAngle); |
| | | Coordinate pt = computePointOnEllipseByAngle(beta, endAngle); |
| | | result.add(pt); |
| | | |
| | | if (!result.get(0).equals(result.get(result.size() - 1))) |
| | | { |
| | | if (!result.get(0).equals(result.get(result.size() - 1))) { |
| | | result.add(result.get(0)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | private Coordinate computePointOnArcByAngle(double beta, double current) |
| | | { |
| | | private Coordinate computePointOnEllipseByAngle(double beta, double current) { |
| | | double sinbeta = Math.sin(beta); |
| | | double cosbeta = Math.cos(beta); |
| | | Coordinate pt = new Coordinate(); |
| | |
| | | return pt; |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.ELLIPSE); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new EllipseElement(raw); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 06:36:55 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public class FrammeAttributeData extends UserAttributeData |
| | | { |
| | | public FrammeAttributeData(short id) |
| | | { |
| | | public class FrammeAttributeData extends UserAttributeData { |
| | | public FrammeAttributeData(short id) { |
| | | super(id, 7); |
| | | } |
| | | |
| | | public FrammeAttributeData(short[] src) |
| | | { |
| | | public FrammeAttributeData(short[] src) { |
| | | super(src); |
| | | } |
| | | |
| | | public short getFsc() |
| | | { |
| | | public short getFsc() { |
| | | int fsc = _src[3] & 0x0000ffff; |
| | | |
| | | return (short) fsc; |
| | | } |
| | | |
| | | public int getUfid() |
| | | { |
| | | public int getUfid() { |
| | | int ufid = (int) (_src[2] << 16 & 0xffff0000); |
| | | |
| | | ufid += _src[1] & 0x0000ffff; |
| | |
| | | return ufid; |
| | | } |
| | | |
| | | public byte getComponentID() |
| | | { |
| | | public byte getComponentID() { |
| | | int cmpid = (int) (_src[5] & 0x000000ff); |
| | | |
| | | return (byte) cmpid; |
| | | } |
| | | |
| | | public byte getRuleNo() |
| | | { |
| | | public byte getRuleNo() { |
| | | int no = (int) ((_src[5] >> 8) & 0x000000ff); |
| | | |
| | | return (byte) no; |
| | | } |
| | | |
| | | public short getStatus() |
| | | { |
| | | public short getStatus() { |
| | | int status = (int) (_src[4] & 0x0000ffff); |
| | | |
| | | return (short) status; |
| | | } |
| | | |
| | | public short getOccID() |
| | | { |
| | | public short getOccID() { |
| | | int occid = (int) (_src[6] & 0x0000ffff); |
| | | |
| | | return (short) occid; |
| | | } |
| | | |
| | | public String toString() |
| | | { |
| | | public String toString() { |
| | | return "FrammeData{" + getFsc() + "," + getUfid() + "," + getComponentID() + "," + getRuleNo() + "," + getStatus() + "," |
| | | + getOccID() + "}"; |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤W¤È 11:38:57 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public interface GeometryConverter |
| | | { |
| | | public interface GeometryConverter { |
| | | public Geometry toGeometry(GeometryFactory factory); |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/17 ¤U¤È 01:50:26 |
| | | * @since 2006/5/17 �U�� 01:50:26 |
| | | */ |
| | | public interface IElementHandler |
| | | { |
| | | public interface IElementHandler { |
| | | public ElementType getElementType(); |
| | | |
| | | public Object read(ByteBuffer buffer, short signature, int length); |
| | | public Element read(ByteBuffer buffer, short signature, int length); |
| | | |
| | | public void write(ByteBuffer buffer, Object element); |
| | | |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤W¤È 11:34:59 |
| | | * @since 2006/5/18 �W�� 11:34:59 |
| | | */ |
| | | public class LineElement extends Element implements GeometryConverter |
| | | { |
| | | public class LineElement extends Element implements GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(LineElement.class); |
| | | |
| | | public LineElement(byte[] raw) |
| | | { |
| | | LineElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public Coordinate getCentroid(double dTolerance) |
| | | { |
| | | public Coordinate getCentroid(double dTolerance) { |
| | | return null; |
| | | } |
| | | |
| | | public Coordinate getEndPoint() |
| | | { |
| | | public Coordinate getEndPoint() { |
| | | int endX = ((raw[22] << 16) & 0xffff0000) | (raw[23] & 0x0000ffff); |
| | | int endY = ((raw[24] << 16) & 0xffff0000) | (raw[25] & 0x0000ffff); |
| | | |
| | |
| | | return new Coordinate(x, y); |
| | | } |
| | | |
| | | public Coordinate getNormal() |
| | | { |
| | | public Coordinate getNormal() { |
| | | return null; |
| | | } |
| | | |
| | | public Coordinate getOrigin() |
| | | { |
| | | public Coordinate getOrigin() { |
| | | return null; |
| | | } |
| | | |
| | | public Coordinate getStartPoint() |
| | | { |
| | | public Coordinate getStartPoint() { |
| | | int startX = ((raw[18] << 16) & 0xffff0000); |
| | | startX = startX + (raw[19] & 0x0000ffff); |
| | | |
| | |
| | | return new Coordinate(x, y); |
| | | } |
| | | |
| | | public Coordinate getVertex(int index) |
| | | { |
| | | public Coordinate getVertex(int index) { |
| | | return (index == 0) |
| | | ? getStartPoint() |
| | | : getEndPoint(); |
| | | } |
| | | |
| | | public double getLength() |
| | | { |
| | | public double getLength() { |
| | | Coordinate p1 = getStartPoint(); |
| | | Coordinate p2 = getEndPoint(); |
| | | |
| | | return DgnUtility.getLength(p1.x, p1.y, p2.x, p2.y); |
| | | } |
| | | |
| | | public Coordinate pointAtDistance(double dDistance, double dTolerance) |
| | | { |
| | | public Coordinate pointAtDistance(double dDistance, double dTolerance) { |
| | | return null; |
| | | } |
| | | |
| | | public Coordinate[] getVertices() |
| | | { |
| | | public Coordinate[] getVertices() { |
| | | Coordinate[] result = new Coordinate[2]; |
| | | |
| | | result[0] = getStartPoint(); |
| | |
| | | return result; |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | return factory.createLineString(getVertices()); |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.LINE); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new LineElement(raw); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 02:48:58 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public class LineStringElement extends Element implements GeometryConverter |
| | | { |
| | | public class LineStringElement extends Element implements GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(LineStringElement.class); |
| | | |
| | | public LineStringElement(byte[] raw) |
| | | { |
| | | LineStringElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public Coordinate getCentroid(double dTolerance) |
| | | { |
| | | public Coordinate getCentroid(double dTolerance) { |
| | | return null; |
| | | } |
| | | |
| | | public Coordinate getEndPoint() |
| | | { |
| | | public Coordinate getEndPoint() { |
| | | return new Coordinate(getX(getVerticeSize() - 1), getY(getVerticeSize() - 1)); |
| | | } |
| | | |
| | | public Coordinate getNormal() |
| | | { |
| | | public Coordinate getNormal() { |
| | | return null; |
| | | } |
| | | |
| | | public Coordinate getOrigin() |
| | | { |
| | | public Coordinate getOrigin() { |
| | | return null; |
| | | } |
| | | |
| | | public Coordinate getStartPoint() |
| | | { |
| | | public Coordinate getStartPoint() { |
| | | return new Coordinate(getX(0), getY(0)); |
| | | } |
| | | |
| | | public Coordinate getVertex(int index) |
| | | { |
| | | public Coordinate getVertex(int index) { |
| | | return (index == 0) |
| | | ? getStartPoint() |
| | | : getEndPoint(); |
| | | } |
| | | |
| | | public int getVerticeSize() |
| | | { |
| | | public int getVerticeSize() { |
| | | return raw[18] & 0x0000ffff; |
| | | } |
| | | |
| | | public double getLength() |
| | | { |
| | | public void setVerticeSize(int size) { |
| | | raw[18] = (short) (size & 0x0000ffff); |
| | | } |
| | | |
| | | public double getLength() { |
| | | double result = 0.0; |
| | | Coordinate[] vset = getVertices(); |
| | | |
| | | for (int i = 1; i < getVerticeSize(); i++) |
| | | { |
| | | for (int i = 1; i < getVerticeSize(); i++) { |
| | | Coordinate p1 = vset[i - 1]; |
| | | Coordinate p2 = vset[i]; |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | public Coordinate pointAtDistance(double dDistance, double dTolerance) |
| | | { |
| | | public Coordinate pointAtDistance(double dDistance, double dTolerance) { |
| | | return null; |
| | | } |
| | | |
| | | public Coordinate[] getVertices() |
| | | { |
| | | public Coordinate[] getVertices() { |
| | | Coordinate[] result = new Coordinate[getVerticeSize()]; |
| | | |
| | | for (int i = 0; i < getVerticeSize(); i++) |
| | | { |
| | | for (int i = 0; i < getVerticeSize(); i++) { |
| | | result[i] = new Coordinate(getX(i), getY(i)); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | return factory.createLineString(getVertices()); |
| | | } |
| | | |
| | | protected double getX(int index) |
| | | { |
| | | if ((index < 0) || (index > getVerticeSize())) |
| | | { |
| | | protected double getX(int index) { |
| | | if ((index < 0) || (index > getVerticeSize())) { |
| | | return -1; |
| | | } |
| | | |
| | |
| | | return DgnUtility.converUnitToCoord(x); |
| | | } |
| | | |
| | | protected void setX(int index, double dx) |
| | | { |
| | | protected void setX(int index, double dx) { |
| | | int newVal = DgnUtility.converCoordToUnit(dx); |
| | | |
| | | raw[19 + (4 * index)] = (short) (newVal >> 16 & 0x0000ffff); |
| | | raw[20 + (4 * index)] = (short) (newVal & 0x0000ffff); |
| | | } |
| | | |
| | | protected double getY(int index) |
| | | { |
| | | if ((index < 0) || (index > getVerticeSize())) |
| | | { |
| | | protected double getY(int index) { |
| | | if ((index < 0) || (index > getVerticeSize())) { |
| | | return -1; |
| | | } |
| | | |
| | |
| | | return DgnUtility.converUnitToCoord(y); |
| | | } |
| | | |
| | | protected void setY(int index, double dy) |
| | | { |
| | | protected void setY(int index, double dy) { |
| | | int newVal = DgnUtility.converCoordToUnit(dy); |
| | | |
| | | raw[21 + (4 * index)] = (short) ((newVal >> 16) & 0x0000ffff); |
| | | raw[22 + (4 * index)] = (short) (newVal & 0x0000ffff); |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.LINESTRING); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new LineStringElement(raw); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤W¤È 10:27:24 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public class Lock |
| | | { |
| | | public class Lock { |
| | | Logger logger = LogManager.getLogger("com.ximple.io.dgn7"); |
| | | |
| | | /** |
| | |
| | | * @return |
| | | * @throws java.io.IOException |
| | | */ |
| | | synchronized boolean canRead() throws IOException |
| | | { |
| | | if ((writer != null) && (writer != Thread.currentThread())) |
| | | { |
| | | synchronized boolean canRead() throws IOException { |
| | | if ((writer != null) && (writer != Thread.currentThread())) { |
| | | return false; |
| | | } |
| | | |
| | | if (writer == null) |
| | | { |
| | | if (writer == null) { |
| | | return true; |
| | | } |
| | | |
| | | if (owners.size() > 1) |
| | | { |
| | | if (owners.size() > 1) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | synchronized boolean canWrite() throws IOException |
| | | { |
| | | if (owners.size() > 1) |
| | | { |
| | | synchronized boolean canWrite() throws IOException { |
| | | if (owners.size() > 1) { |
| | | return false; |
| | | } |
| | | |
| | | if ((canRead()) && ((writer == Thread.currentThread()) || (writer == null))) |
| | | { |
| | | if (owners.isEmpty()) |
| | | { |
| | | if ((canRead()) && ((writer == Thread.currentThread()) || (writer == null))) { |
| | | if (owners.isEmpty()) { |
| | | return true; |
| | | } |
| | | |
| | | if (owners.containsKey(Thread.currentThread())) |
| | | { |
| | | if (owners.containsKey(Thread.currentThread())) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | * |
| | | * @throws IOException |
| | | */ |
| | | public synchronized void lockRead() throws IOException |
| | | { |
| | | if (!canRead()) |
| | | { |
| | | while ((writeLocks > 0) || (writer != null)) |
| | | { |
| | | try |
| | | { |
| | | public synchronized void lockRead() throws IOException { |
| | | if (!canRead()) { |
| | | while ((writeLocks > 0) || (writer != null)) { |
| | | try { |
| | | wait(); |
| | | } catch (InterruptedException e) |
| | | { |
| | | } catch (InterruptedException e) { |
| | | throw (IOException) new IOException().initCause(e); |
| | | } |
| | | } |
| | |
| | | Thread current = Thread.currentThread(); |
| | | Owner owner = (Owner) owners.get(current); |
| | | |
| | | if (owner != null) |
| | | { |
| | | if (owner != null) { |
| | | owner.timesLocked++; |
| | | } else |
| | | { |
| | | } else { |
| | | owner = new Owner(current); |
| | | owners.put(current, owner); |
| | | } |
| | |
| | | logger.debug("Start Read Lock:" + owner); |
| | | } |
| | | |
| | | private void assertTrue(String message, boolean b) |
| | | { |
| | | if (!b) |
| | | { |
| | | private void assertTrue(String message, boolean b) { |
| | | if (!b) { |
| | | throw new AssertionError(message); |
| | | } |
| | | } |
| | |
| | | * Called by ShapefileReader after a read is complete and after the IOStream |
| | | * is closed. |
| | | */ |
| | | public synchronized void unlockRead() |
| | | { |
| | | public synchronized void unlockRead() { |
| | | assertTrue("Current thread does not have a readLock", owners.containsKey(Thread.currentThread())); |
| | | |
| | | Owner owner = (Owner) owners.get(Thread.currentThread()); |
| | |
| | | assertTrue("Current thread has " + owner.timesLocked + "negative number of locks", owner.timesLocked > 0); |
| | | owner.timesLocked--; |
| | | |
| | | if (owner.timesLocked == 0) |
| | | { |
| | | if (owner.timesLocked == 0) { |
| | | owners.remove(Thread.currentThread()); |
| | | } |
| | | |
| | |
| | | * |
| | | * @throws IOException |
| | | */ |
| | | public synchronized void lockWrite() throws IOException |
| | | { |
| | | public synchronized void lockWrite() throws IOException { |
| | | Thread currentThread = Thread.currentThread(); |
| | | |
| | | if (writer == null) |
| | | { |
| | | if (writer == null) { |
| | | writer = currentThread; |
| | | } |
| | | |
| | | while (!canWrite()) |
| | | { |
| | | try |
| | | { |
| | | while (!canWrite()) { |
| | | try { |
| | | wait(); |
| | | } catch (InterruptedException e) |
| | | { |
| | | } catch (InterruptedException e) { |
| | | throw (IOException) new IOException().initCause(e); |
| | | } |
| | | |
| | | if (writer == null) |
| | | { |
| | | if (writer == null) { |
| | | writer = currentThread; |
| | | } |
| | | } |
| | | |
| | | if (writer == null) |
| | | { |
| | | if (writer == null) { |
| | | writer = currentThread; |
| | | } |
| | | |
| | |
| | | /** |
| | | * default visibility for tests |
| | | */ |
| | | synchronized int getReadLocks(Thread thread) |
| | | { |
| | | synchronized int getReadLocks(Thread thread) { |
| | | Owner owner = (Owner) owners.get(thread); |
| | | |
| | | if (owner == null) |
| | | { |
| | | if (owner == null) { |
| | | return -1; |
| | | } |
| | | |
| | | return owner.timesLocked; |
| | | } |
| | | |
| | | public synchronized void unlockWrite() |
| | | { |
| | | if (writeLocks > 0) |
| | | { |
| | | public synchronized void unlockWrite() { |
| | | if (writeLocks > 0) { |
| | | assertTrue("current thread does not own the write lock", writer == Thread.currentThread()); |
| | | assertTrue("writeLock has already been unlocked", writeLocks > 0); |
| | | writeLocks--; |
| | | |
| | | if (writeLocks == 0) |
| | | { |
| | | if (writeLocks == 0) { |
| | | writer = null; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * default visibility for tests |
| | | */ |
| | | synchronized boolean ownWriteLock(Thread thread) |
| | | { |
| | | synchronized boolean ownWriteLock(Thread thread) { |
| | | return (writer == thread) && (writeLocks > 0); |
| | | } |
| | | |
| | | private class Owner |
| | | { |
| | | private class Owner { |
| | | final Thread owner; |
| | | int timesLocked; |
| | | |
| | | Owner(Thread owner) |
| | | { |
| | | Owner(Thread owner) { |
| | | this.owner = owner; |
| | | timesLocked = 1; |
| | | } |
| | | |
| | | public String toString() |
| | | { |
| | | public String toString() { |
| | | return owner.getName() + " has " + timesLocked + " locks"; |
| | | } |
| | | } |
| | |
| | | * @source $URL$ |
| | | * @since 2.0 |
| | | */ |
| | | public class NIOUtilities |
| | | { |
| | | public class NIOUtilities { |
| | | /** |
| | | * {@code true} if a warning has already been logged. |
| | | */ |
| | |
| | | * @todo This constructor will become private when {@code NIOBufferUtils} |
| | | * will have been removed. |
| | | */ |
| | | protected NIOUtilities() |
| | | { |
| | | protected NIOUtilities() { |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return true if the operation was successful, false otherwise. |
| | | * @see java.nio.MappedByteBuffer |
| | | */ |
| | | public static boolean clean(final ByteBuffer buffer) |
| | | { |
| | | if (buffer == null || !buffer.isDirect()) |
| | | { |
| | | public static boolean clean(final ByteBuffer buffer) { |
| | | if (buffer == null || !buffer.isDirect()) { |
| | | return false; |
| | | } |
| | | Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction() |
| | | { |
| | | public Object run() |
| | | { |
| | | Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction() { |
| | | public Object run() { |
| | | Boolean success = Boolean.FALSE; |
| | | try |
| | | { |
| | | try { |
| | | Method getCleanerMethod = buffer.getClass().getMethod("cleaner", (Class[]) null); |
| | | getCleanerMethod.setAccessible(true); |
| | | Object cleaner = getCleanerMethod.invoke(buffer, (Object[]) null); |
| | | Method clean = cleaner.getClass().getMethod("clean", (Class[]) null); |
| | | clean.invoke(cleaner, (Object[]) null); |
| | | success = Boolean.TRUE; |
| | | } catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | // This really is a show stopper on windows |
| | | if (isLoggable()) |
| | | { |
| | | if (isLoggable()) { |
| | | log(e, buffer); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * Check if a warning message should be logged. |
| | | */ |
| | | private static synchronized boolean isLoggable() |
| | | { |
| | | try |
| | | { |
| | | private static synchronized boolean isLoggable() { |
| | | try { |
| | | return !warned && ( |
| | | System.getProperty("org.geotools.io.debugBuffer", "false").equalsIgnoreCase("true") || |
| | | System.getProperty("os.name").indexOf("Windows") >= 0); |
| | | } catch (SecurityException exception) |
| | | { |
| | | } catch (SecurityException exception) { |
| | | // The utilities may be running in an Applet, in which case we |
| | | // can't read properties. Assumes we are not in debugging mode. |
| | | return false; |
| | |
| | | /** |
| | | * Log a warning message. |
| | | */ |
| | | private static synchronized void log(final Exception e, final ByteBuffer buffer) |
| | | { |
| | | private static synchronized void log(final Exception e, final ByteBuffer buffer) { |
| | | warned = true; |
| | | String message = "Error attempting to close a mapped byte buffer : " + buffer.getClass().getName() |
| | | + "\n JVM : " + System.getProperty("java.version") |
| | |
| | | |
| | | import org.apache.log4j.Logger; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.LinearRing; |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | |
| | | /** |
| | | * ShapeElement |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 03:08:43 |
| | | * @since 2006/5/18 �U�� 03:08:43 |
| | | */ |
| | | public class ShapeElement extends LineStringElement implements GeometryConverter |
| | | { |
| | | public class ShapeElement extends LineStringElement implements GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(ShapeElement.class); |
| | | |
| | | public ShapeElement(byte[] raw) |
| | | { |
| | | ShapeElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public Coordinate[] getVertices() |
| | | { |
| | | public Coordinate[] getVertices() { |
| | | Coordinate[] result = super.getVertices(); |
| | | if ((result != null) && (result.length > 2)) |
| | | { |
| | | if ((result != null) && (result.length > 2)) { |
| | | boolean isClosed = result[0].equals2D(result[result.length - 1]); |
| | | if (!isClosed) |
| | | { |
| | | if (!isClosed) { |
| | | double distance = result[0].distance(result[result.length - 1]); |
| | | if (distance < 0.00210) |
| | | { |
| | | if (distance < 0.00210) { |
| | | result[result.length - 1] = new Coordinate(result[0]); |
| | | } else |
| | | { |
| | | } else { |
| | | logger.info("Shape is not closed. distance=" + distance); |
| | | logger.debug("result[0]=" + result[0].toString()); |
| | | logger.debug("result[length - 1]=" + result[result.length - 1]); |
| | |
| | | return result; |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | try |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | try { |
| | | LinearRing ring = factory.createLinearRing(this.getVertices()); |
| | | return factory.createPolygon(ring, null); |
| | | } catch (IllegalArgumentException e) |
| | | { |
| | | } catch (IllegalArgumentException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.SHAPE); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new ShapeElement(raw); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤W¤È 10:31:08 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public class StreamLogging |
| | | { |
| | | public class StreamLogging { |
| | | private static final Logger LOGGER = LogManager.getLogger("com.ximple.io.dgn7"); |
| | | private String name; |
| | | private int open = 0; |
| | |
| | | * |
| | | * @param name |
| | | */ |
| | | public StreamLogging(String name) |
| | | { |
| | | public StreamLogging(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | /** |
| | | * Call when reader or writer is opened |
| | | */ |
| | | public synchronized void open() |
| | | { |
| | | public synchronized void open() { |
| | | open++; |
| | | LOGGER.debug(name + " has been opened. Number open: " + open); |
| | | } |
| | | |
| | | public synchronized void close() |
| | | { |
| | | public synchronized void close() { |
| | | open--; |
| | | LOGGER.debug(name + " has been closed. Number open: " + open); |
| | | } |
| | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | public class TagElement extends Element implements GeometryConverter |
| | | { |
| | | public class TagElement extends Element implements GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(TagElement.class); |
| | | |
| | | public TagElement(byte[] raw) |
| | | { |
| | | TagElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | return null; |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.TAG); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new TagElement(raw); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 05:03:46 |
| | | * @since 2006/5/18 �U�� 05:03:46 |
| | | */ |
| | | public class TcbElement extends Element |
| | | { |
| | | public class TcbElement extends Element { |
| | | private static final Logger logger = Logger.getLogger(TcbElement.class); |
| | | |
| | | public TcbElement(byte[] raw) |
| | | { |
| | | TcbElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public boolean is2D() |
| | | { |
| | | public boolean is2D() { |
| | | int dimension = (int) (raw[607] & 0x00000004); |
| | | |
| | | if (dimension == 0) |
| | | { |
| | | if (dimension == 0) { |
| | | return true; |
| | | } else |
| | | { |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public String getMasterUnitName() |
| | | { |
| | | public String getMasterUnitName() { |
| | | byte[] master = new byte[1]; |
| | | |
| | | master[0] = (byte) (raw[560] & 0x00ff); |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public String getSubUnitName() |
| | | { |
| | | public String getSubUnitName() { |
| | | byte[] sub = new byte[2]; |
| | | |
| | | sub[0] = (byte) (raw[561] & 0x00ff); |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public int getGraphicGroup() |
| | | { |
| | | public int getGraphicGroup() { |
| | | return (int) (raw[594] & 0x0000ffff); |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.TCB); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new TcbElement(raw); |
| | | } |
| | | } |
| | |
| | | package com.ximple.io.dgn7; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.ximple.util.DgnUtility; |
| | | import org.apache.log4j.Logger; |
| | | |
| | | import java.awt.geom.AffineTransform; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.CharBuffer; |
| | |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.CharsetDecoder; |
| | | |
| | | import org.apache.log4j.Logger; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | |
| | | import com.ximple.util.DgnUtility; |
| | | |
| | | /** |
| | | * TextElement |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤W¤È 11:45:29 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public class TextElement extends Element implements GeometryConverter |
| | | { |
| | | public class TextElement extends Element implements GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(TextElement.class); |
| | | |
| | | public static final int ED_CENTERJUSTIFICATION = 0; |
| | |
| | | public static final int TXTJUST_RD = 24; /* Right Descender */ |
| | | public static final int TXTJUST_NONE = 127;/* no justfication */ |
| | | |
| | | public TextElement(byte[] raw) |
| | | { |
| | | TextElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public Coordinate getOrigin() |
| | | { |
| | | public Coordinate getOrigin() { |
| | | int x = (raw[25] << 16 & 0xffff0000); |
| | | |
| | | x += raw[26] & 0x0000ffff; |
| | |
| | | return new Coordinate(dx, dy); |
| | | } |
| | | |
| | | public int getFontIndex() |
| | | { |
| | | public int getFontIndex() { |
| | | return (int) raw[18] & 0x00000000ff; |
| | | } |
| | | |
| | | public boolean hasSlant() |
| | | { |
| | | public boolean hasSlant() { |
| | | return true; |
| | | } |
| | | |
| | | public boolean hasUnderline() |
| | | { |
| | | public boolean hasUnderline() { |
| | | return true; |
| | | } |
| | | |
| | | public boolean isFixedWidthSpacing() |
| | | { |
| | | public boolean isFixedWidthSpacing() { |
| | | return true; |
| | | } |
| | | |
| | | public boolean isPlanar() |
| | | { |
| | | public boolean isPlanar() { |
| | | return true; |
| | | } |
| | | |
| | | public boolean isVertical() |
| | | { |
| | | public boolean isVertical() { |
| | | return true; |
| | | } |
| | | |
| | | public double getTextHeight() |
| | | { |
| | | public double getTextHeight() { |
| | | int height = ((raw[21] << 16) & 0xffff0000); |
| | | |
| | | height += raw[22] & 0x0000ffff; |
| | |
| | | return DgnUtility.converIntToDouble(height); |
| | | } |
| | | |
| | | public double getTextWidth() |
| | | { |
| | | public double getTextWidth() { |
| | | int length = (raw[19] << 16 & 0xffff0000); |
| | | |
| | | length += raw[20] & 0x0000ffff; |
| | |
| | | return DgnUtility.converIntToDouble(length); |
| | | } |
| | | |
| | | public int getJustification() |
| | | { |
| | | public int getJustification() { |
| | | return ((raw[18] >>> 8) & 0x00000000ff); |
| | | } |
| | | |
| | | public double getRotationAngle() |
| | | { |
| | | public double getRotationAngle() { |
| | | int totation = ((raw[23] & 0x0000ffff) << 16) | (raw[24] & 0x0000ffff); |
| | | return DgnUtility.converIntToRotation(totation); |
| | | } |
| | | |
| | | public boolean isChinese() |
| | | { |
| | | public boolean isChinese() { |
| | | if (raw.length < 31) return false; |
| | | int isChinese = raw[30] & 0x0000ffff; |
| | | |
| | | return (isChinese == 0xfdff); |
| | | } |
| | | |
| | | public int getTextLength() |
| | | { |
| | | public int getTextLength() { |
| | | int num = raw[29]; |
| | | |
| | | if (isChinese()) |
| | | { |
| | | if (isChinese()) { |
| | | num = (num / 2) - 1; |
| | | } |
| | | |
| | | return num; |
| | | } |
| | | |
| | | public String getText() |
| | | { |
| | | public String getText() { |
| | | StringBuilder val = new StringBuilder(); |
| | | char[] temp; |
| | | int num = getTextLength(); |
| | | if (num < 0) { |
| | | logger.warn("getTextLength() return Negative Value."); |
| | | return ""; |
| | | } |
| | | |
| | | if (!isChinese()) |
| | | { |
| | | if (30 + num / 2 > raw.length) { |
| | | logger.warn("getTextLength() too long."); |
| | | return ""; |
| | | } |
| | | |
| | | if (!isChinese()) { |
| | | temp = new char[num]; |
| | | |
| | | for (int i = 0; i < temp.length; i++) |
| | | { |
| | | if ((i % 2) == 0) |
| | | { |
| | | for (int i = 0; i < temp.length; i++) { |
| | | if ((i % 2) == 0) { |
| | | temp[i] = (char) (raw[30 + (int) (i / 2)] & (short) 0x00ff); |
| | | } else |
| | | { |
| | | } else { |
| | | temp[i] = (char) ((raw[30 + (int) (i / 2)] >> 8) & (short) 0x00ff); |
| | | } |
| | | |
| | | val.append(temp[i]); |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | byte[] strRaw = new byte[num * 2]; |
| | | for (int i = 0; i < num; i++) |
| | | { |
| | | for (int i = 0; i < num; i++) { |
| | | short charValue = raw[i + 31]; |
| | | byte hi = (byte) (charValue >>> 8); |
| | | byte lo = (byte) charValue; |
| | |
| | | strRaw[i * 2 + 1] = lo; |
| | | } |
| | | |
| | | try |
| | | { |
| | | try { |
| | | Charset charsetBig5 = Charset.forName("Big5"); |
| | | CharsetDecoder decoder = charsetBig5.newDecoder(); |
| | | CharBuffer cb = decoder.decode(ByteBuffer.wrap(strRaw)); |
| | | val.append(cb); |
| | | } catch (CharacterCodingException e) |
| | | { |
| | | } catch (CharacterCodingException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | return val.toString(); |
| | | } finally |
| | | { |
| | | } finally { |
| | | // rawBuffer.position(pos); |
| | | // rawBuffer.order(order); |
| | | } |
| | |
| | | return val.toString(); |
| | | } |
| | | |
| | | protected byte[] convertDBCSToUnicode(byte[] buffer) |
| | | { |
| | | protected byte[] convertDBCSToUnicode(byte[] buffer) { |
| | | byte[] charBuffer = new byte[4]; |
| | | charBuffer[0] = (byte) ((byte) ((buffer[1] & 0xc0) >>> 6) | 0xc0); |
| | | charBuffer[1] = (byte) (buffer[1] & 0x3f | 0x80); |
| | |
| | | return charBuffer; |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | return factory.createPoint(getUserOrigin()); |
| | | } |
| | | |
| | | public Geometry toAnchorGeometry(GeometryFactory factory) |
| | | { |
| | | if (getText() == null) |
| | | { |
| | | public Geometry toAnchorGeometry(GeometryFactory factory) { |
| | | if (getText() == null) { |
| | | return factory.createMultiPoint(new Coordinate[] {}); |
| | | } |
| | | |
| | | return factory.createMultiPoint(toAnchorCoordinates()); |
| | | } |
| | | |
| | | public Coordinate[] toAnchorCoordinates() |
| | | { |
| | | public Coordinate[] toAnchorCoordinates() { |
| | | CoordinateList result = new CoordinateList(); |
| | | int len = getText().trim().length(); |
| | | if (len == 0) return result.toCoordinateArray(); |
| | |
| | | at.setToRotation(angle, p.x, p.y); |
| | | at.scale(1, 1); |
| | | |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | for (int i = 0; i < len; i++) { |
| | | double[] srcPt = new double[2]; |
| | | double[] dstPt = new double[2]; |
| | | |
| | |
| | | return result.toCoordinateArray(); |
| | | } |
| | | |
| | | private double getUserWidth() |
| | | { |
| | | private double getUserWidth() { |
| | | int just = getJustification(); |
| | | // Envelope range = getRange(); // case -1 |
| | | // double width = (range.getWidth()); // case -1 |
| | | // double width = this.getTextWidth() * this.getTextLength() * 1000.0; // case -2 |
| | | double width = (this.getTextWidth() * this.getTextLength()); |
| | | |
| | | switch (just) |
| | | { |
| | | switch (just) { |
| | | case TXTJUST_LT: |
| | | case TXTJUST_LC: |
| | | case TXTJUST_LB: |
| | |
| | | return width; |
| | | } |
| | | |
| | | private double getUserHeight() |
| | | { |
| | | private double getUserHeight() { |
| | | int just = getJustification(); |
| | | double height = getTextHeight(); |
| | | |
| | | switch (just) |
| | | { |
| | | switch (just) { |
| | | case TXTJUST_LB: |
| | | case TXTJUST_CB: |
| | | case TXTJUST_RB: // bottom |
| | |
| | | return height; |
| | | } |
| | | |
| | | public Coordinate getUserOrigin() |
| | | { |
| | | public Coordinate getUserOrigin() { |
| | | double width = getUserWidth(); |
| | | double height = getUserHeight(); |
| | | double angle = Math.toRadians(getRotationAngle()); |
| | |
| | | return new Coordinate(dstPt[0], dstPt[1]); |
| | | } |
| | | |
| | | public Object clone() throws CloneNotSupportedException |
| | | { |
| | | public Object clone() throws CloneNotSupportedException { |
| | | int pos = this.rawBuffer.position(); |
| | | this.rawBuffer.position(0); |
| | | byte[] rawBytes = this.rawBuffer.array(); |
| | |
| | | return other; |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.TEXT); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new TextElement(raw); |
| | | } |
| | | } |
| | |
| | | import org.apache.log4j.Logger; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | |
| | | import com.ximple.util.DgnUtility; |
| | | |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 04:02:58 |
| | | * @since 2006/5/18 �U�� 04:02:58 |
| | | */ |
| | | public class TextNodeElement extends Element implements ComplexElement, GeometryConverter |
| | | { |
| | | public class TextNodeElement extends Element implements ComplexElement, GeometryConverter { |
| | | private static final Logger logger = Logger.getLogger(TextElement.class); |
| | | |
| | | private ArrayList<Element> list = new ArrayList<Element>(); |
| | | |
| | | public TextNodeElement(byte[] raw) |
| | | { |
| | | TextNodeElement(byte[] raw) { |
| | | super(raw); |
| | | } |
| | | |
| | | public int size() |
| | | { |
| | | public int size() { |
| | | return list.size(); |
| | | } |
| | | |
| | | public boolean isEmpty() |
| | | { |
| | | public boolean isEmpty() { |
| | | return list.isEmpty(); |
| | | } |
| | | |
| | | public boolean contains(Object o) |
| | | { |
| | | public boolean contains(Object o) { |
| | | return list.contains(o); |
| | | } |
| | | |
| | | public Iterator<Element> iterator() |
| | | { |
| | | public Iterator<Element> iterator() { |
| | | return list.iterator(); |
| | | } |
| | | |
| | | public Object[] toArray() |
| | | { |
| | | public Object[] toArray() { |
| | | return list.toArray(); |
| | | } |
| | | |
| | | public <T> T[] toArray(T[] ts) |
| | | { |
| | | public <T> T[] toArray(T[] ts) { |
| | | return list.toArray(ts); |
| | | } |
| | | |
| | | public boolean add(Element element) |
| | | { |
| | | public boolean add(Element element) { |
| | | return list.add(element); |
| | | } |
| | | |
| | | public boolean remove(Object o) |
| | | { |
| | | public boolean remove(Object o) { |
| | | return list.remove(o); |
| | | } |
| | | |
| | | public boolean containsAll(Collection<?> objects) |
| | | { |
| | | public boolean containsAll(Collection<?> objects) { |
| | | return list.containsAll(objects); |
| | | } |
| | | |
| | | public boolean addAll(Collection<? extends Element> elements) |
| | | { |
| | | public boolean addAll(Collection<? extends Element> elements) { |
| | | return list.addAll(elements); |
| | | } |
| | | |
| | | public boolean addAll(int i, Collection<? extends Element> elements) |
| | | { |
| | | public boolean addAll(int i, Collection<? extends Element> elements) { |
| | | return list.addAll(i, elements); |
| | | } |
| | | |
| | | public boolean removeAll(Collection<?> objects) |
| | | { |
| | | public boolean removeAll(Collection<?> objects) { |
| | | return list.removeAll(objects); |
| | | } |
| | | |
| | | public boolean retainAll(Collection<?> objects) |
| | | { |
| | | public boolean retainAll(Collection<?> objects) { |
| | | return list.retainAll(objects); |
| | | } |
| | | |
| | | public void clear() |
| | | { |
| | | public void clear() { |
| | | list.clear(); |
| | | } |
| | | |
| | | public Element get(int index) |
| | | { |
| | | public Element get(int index) { |
| | | return list.get(index); |
| | | } |
| | | |
| | | public Element set(int index, Element element) |
| | | { |
| | | public Element set(int index, Element element) { |
| | | return list.set(index, element); |
| | | } |
| | | |
| | | public void add(int index, Element element) |
| | | { |
| | | public void add(int index, Element element) { |
| | | list.add(index, element); |
| | | } |
| | | |
| | | public Element remove(int index) |
| | | { |
| | | public Element remove(int index) { |
| | | return list.remove(index); |
| | | } |
| | | |
| | | public int indexOf(Object o) |
| | | { |
| | | public int indexOf(Object o) { |
| | | return list.indexOf(o); |
| | | } |
| | | |
| | | public int lastIndexOf(Object o) |
| | | { |
| | | public int lastIndexOf(Object o) { |
| | | return list.lastIndexOf(o); |
| | | } |
| | | |
| | | public ListIterator<Element> listIterator() |
| | | { |
| | | public ListIterator<Element> listIterator() { |
| | | return list.listIterator(); |
| | | } |
| | | |
| | | public ListIterator<Element> listIterator(int index) |
| | | { |
| | | public ListIterator<Element> listIterator(int index) { |
| | | return list.listIterator(index); |
| | | } |
| | | |
| | | public List<Element> subList(int fromIndex, int toIndex) |
| | | { |
| | | public List<Element> subList(int fromIndex, int toIndex) { |
| | | return list.subList(fromIndex, toIndex); |
| | | } |
| | | |
| | | public Element[] toArray(Element[] a) |
| | | { |
| | | public Element[] toArray(Element[] a) { |
| | | return list.toArray(a); |
| | | } |
| | | |
| | | public String[] getTextArray() |
| | | { |
| | | public String[] getTextArray() { |
| | | ArrayList<String> list = new ArrayList<String>(); |
| | | |
| | | for (ListIterator it = listIterator(); it.hasNext();) |
| | | { |
| | | for (ListIterator it = listIterator(); it.hasNext();) { |
| | | Element element = (Element) it.next(); |
| | | |
| | | if (element instanceof TextElement) |
| | | { |
| | | if (element instanceof TextElement) { |
| | | list.add(((TextElement) element).getText()); |
| | | } |
| | | } |
| | |
| | | return list.toArray(new String[list.size()]); |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | /* |
| | | * CoordinateList coords = new CoordinateList(); |
| | | * for (ListIterator it = listIterator(); it.hasNext(); ) |
| | |
| | | // return factory.createMultiPoint(coords.toCoordinateArray()); |
| | | } |
| | | |
| | | public Geometry toAnchorGeometry(GeometryFactory factory) |
| | | { |
| | | public Geometry toAnchorGeometry(GeometryFactory factory) { |
| | | CoordinateList coords = new CoordinateList(); |
| | | for (int i = 0; i < size(); i++) |
| | | { |
| | | for (int i = 0; i < size(); i++) { |
| | | TextElement txtElm = (TextElement) get(i); |
| | | coords.add(txtElm.toAnchorCoordinates(), false); |
| | | } |
| | | return factory.createMultiPoint(coords.toCoordinateArray()); |
| | | } |
| | | |
| | | public int getTotalWords() |
| | | { |
| | | public int getTotalWords() { |
| | | return (raw[18] & 0x0000ffff); |
| | | } |
| | | |
| | | public void setTotalWords(int value) |
| | | { |
| | | public void setTotalWords(int value) { |
| | | raw[18] = (short) (value & 0x0000ffff); |
| | | } |
| | | |
| | | public int getNumString() |
| | | { |
| | | public int getNumString() { |
| | | return (raw[19] & 0x0000ffff); |
| | | } |
| | | |
| | | public void setNumString(int value) |
| | | { |
| | | public void setNumString(int value) { |
| | | raw[19] = (short) (value & 0x0000ffff); |
| | | } |
| | | |
| | | public int getNodeNumber() |
| | | { |
| | | public int getNodeNumber() { |
| | | return (raw[20] & 0x0000ffff); |
| | | } |
| | | |
| | | public void setNodeNumber(int value) |
| | | { |
| | | public void setNodeNumber(int value) { |
| | | raw[20] = (short) (value & 0x0000ffff); |
| | | } |
| | | |
| | | public int getMaxLength() |
| | | { |
| | | public int getMaxLength() { |
| | | return (raw[21] & 0x00ff); |
| | | } |
| | | |
| | | public void setMaxLength(int value) |
| | | { |
| | | public void setMaxLength(int value) { |
| | | raw[21] = (short) ((value & 0x00ff) | (raw[21] & 0xff00)); |
| | | } |
| | | |
| | | public int getMaxUsed() |
| | | { |
| | | public int getMaxUsed() { |
| | | return ((raw[21] >> 8) & 0x00ff); |
| | | } |
| | | |
| | | public void setMaxUsed(int value) |
| | | { |
| | | public void setMaxUsed(int value) { |
| | | raw[21] = (short) (((value << 8) & 0xff00) | (raw[21] & 0x00ff)); |
| | | } |
| | | |
| | | public int getJustification() |
| | | { |
| | | public int getJustification() { |
| | | return ((raw[22] >> 8) & 0x00ff); |
| | | } |
| | | |
| | | public void setJustification(int value) |
| | | { |
| | | public void setJustification(int value) { |
| | | raw[22] = (short) (((value << 8) & 0xff00) | (raw[22] & 0x00ff)); |
| | | } |
| | | |
| | | public int getFontIndex() |
| | | { |
| | | public int getFontIndex() { |
| | | return (raw[22] & 0x00ff); |
| | | } |
| | | |
| | | public void setFontIndex(int value) |
| | | { |
| | | public void setFontIndex(int value) { |
| | | raw[22] = (short) ((value & 0x00ff) | (raw[22] & 0xff00)); |
| | | } |
| | | |
| | | public double getLineSpacing() |
| | | { |
| | | public double getLineSpacing() { |
| | | int lineSpace; |
| | | lineSpace = ((raw[23] & 0x0000ffff) << 16) | (raw[24] & 0x0000ffff); |
| | | |
| | | return lineSpace; |
| | | } |
| | | |
| | | public void setLineSpacing(double value) |
| | | { |
| | | public void setLineSpacing(double value) { |
| | | int temp = (int) (value*1000.0); |
| | | raw[23] = (short) ((temp >> 16) & 0x0000ffff); |
| | | raw[24] = (short) (temp & 0x0000ffff); |
| | | } |
| | | |
| | | public double getTextNodeLength() |
| | | { |
| | | public double getTextNodeLength() { |
| | | int lengthMult; |
| | | |
| | | lengthMult = ((raw[25] << 16) & 0xffff0000); |
| | |
| | | return DgnUtility.converIntToDouble(lengthMult); |
| | | } |
| | | |
| | | public void setTextNodeLength(double value) |
| | | { |
| | | public void setTextNodeLength(double value) { |
| | | int temp = DgnUtility.converDoubleToInt(value); |
| | | raw[25] = (short) ((temp >> 16) & 0x0000ffff); |
| | | raw[26] = (short) (temp & 0x0000ffff); |
| | | } |
| | | |
| | | public double getTextNodeHeight() |
| | | { |
| | | public double getTextNodeHeight() { |
| | | int heightMult; |
| | | |
| | | heightMult = ((raw[27] << 16) & 0xffff0000); |
| | |
| | | return DgnUtility.converIntToDouble(heightMult); |
| | | } |
| | | |
| | | public void setTextNodeHeight(double value) |
| | | { |
| | | public void setTextNodeHeight(double value) { |
| | | int temp = DgnUtility.converDoubleToInt(value); |
| | | raw[27] = (short) ((temp >> 16) & 0x0000ffff); |
| | | raw[28] = (short) (temp & 0x0000ffff); |
| | | } |
| | | |
| | | public double getRotationAngle() |
| | | { |
| | | public double getRotationAngle() { |
| | | int rotation = (raw[29] << 16 & 0xffff0000); |
| | | rotation += raw[30]; |
| | | |
| | | return DgnUtility.converIntToRotation(rotation); |
| | | } |
| | | |
| | | public void setRotationAngle(double value) |
| | | { |
| | | public void setRotationAngle(double value) { |
| | | int temp = DgnUtility.converRotatioToInt(value); |
| | | raw[29] = (short) (temp >> 16 & 0x0000ffff); |
| | | raw[30] = (short) (temp & 0x0000ffff); |
| | | } |
| | | |
| | | public Coordinate getOrigin() |
| | | { |
| | | public Coordinate getOrigin() { |
| | | int x = ((raw[31] << 16) & 0xffff0000) | (raw[32] & 0x0000ffff); |
| | | double dx = DgnUtility.converUnitToCoord(x); |
| | | // return DgnUtility.convertFromDGN(x); |
| | |
| | | return new Coordinate(dx, dy); |
| | | } |
| | | |
| | | public void setOrigin(Coordinate value) |
| | | { |
| | | public void setOrigin(Coordinate value) { |
| | | int x = DgnUtility.converCoordToUnit(value.x); |
| | | raw[31] = (short) (x >> 16 & 0x0000ffff); |
| | | raw[32] = (short) (x & 0x0000ffff); |
| | |
| | | raw[34] = (short) (y & 0x0000ffff); |
| | | } |
| | | |
| | | public Object clone() throws CloneNotSupportedException |
| | | { |
| | | public Object clone() throws CloneNotSupportedException { |
| | | int pos = this.rawBuffer.position(); |
| | | this.rawBuffer.position(0); |
| | | byte[] rawBytes = this.rawBuffer.array(); |
| | |
| | | this.rawBuffer.position(pos); |
| | | |
| | | TextNodeElement other = new TextNodeElement(otherRaw); |
| | | for (Object o : this) |
| | | { |
| | | for (Object o : this) { |
| | | TextElement textElm = (TextElement) o; |
| | | other.add((Element) textElm.clone()); |
| | | } |
| | |
| | | return other; |
| | | } |
| | | |
| | | public static class ElementHandler extends Element.ElementHandler |
| | | { |
| | | public static class ElementHandler extends Element.ElementHandler { |
| | | private static ElementHandler instance = null; |
| | | |
| | | public ElementHandler() |
| | | { |
| | | public ElementHandler() { |
| | | super(ElementType.TEXTNODE); |
| | | } |
| | | |
| | | public static IElementHandler getInstance() |
| | | { |
| | | if (instance == null) |
| | | { |
| | | public static IElementHandler getInstance() { |
| | | if (instance == null) { |
| | | instance = new ElementHandler(); |
| | | } |
| | | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | protected Element createElement(byte[] raw) { |
| | | return new TextNodeElement(raw); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 02:29:29 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public class UserAttributeData |
| | | { |
| | | public class UserAttributeData { |
| | | protected short[] _src; |
| | | |
| | | public UserAttributeData(short id, int attributeCount) |
| | | { |
| | | public UserAttributeData(short id, int attributeCount) { |
| | | _src = new short[attributeCount]; |
| | | _src[0] = id; |
| | | } |
| | | |
| | | public UserAttributeData(short[] src) |
| | | { |
| | | public UserAttributeData(short[] src) { |
| | | _src = src; |
| | | } |
| | | |
| | | public short getID() |
| | | { |
| | | public short getID() { |
| | | return _src[0]; |
| | | } |
| | | |
| | | public void setID(short value) |
| | | { |
| | | public void setID(short value) { |
| | | _src[0] = value; |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Ulysses |
| | | * @version 0.1 |
| | | * @since 2006/5/18 ¤U¤È 01:33:00 |
| | | * @since 2006/5/18 |
| | | */ |
| | | public final class DgnUtility |
| | | { |
| | | public final class DgnUtility { |
| | | private static final Logger logger = Logger.getLogger(DgnUtility.class); |
| | | |
| | | public static double converIntToDouble(int src) |
| | | { |
| | | public static double converIntToDouble(int src) { |
| | | return (double) ((long) ((src * 6) / 1000.0 + 0.5)) / 1000.0; |
| | | } |
| | | |
| | | public static int converDoubleToInt(double src) |
| | | { |
| | | public static int converDoubleToInt(double src) { |
| | | |
| | | return (int) (src / 6 * 1000000.0); |
| | | } |
| | | |
| | | public static int convertFromDGN(int aValue) |
| | | { |
| | | public static int convertFromDGN(int aValue) { |
| | | int newVal; |
| | | |
| | | newVal = (((aValue ^ 0x00008000) << 16) & 0xffff0000); |
| | |
| | | return newVal; |
| | | } |
| | | |
| | | public static int converToDGN(int aValue) |
| | | { |
| | | public static int converToDGN(int aValue) { |
| | | int newVal; |
| | | |
| | | newVal = (aValue << 16 & 0xffff0000); |
| | |
| | | return newVal; |
| | | } |
| | | |
| | | public static double converIntToRotation(int aValue) |
| | | { |
| | | public static double converIntToRotation(int aValue) { |
| | | |
| | | return aValue / 360000.0; |
| | | } |
| | | |
| | | public static int converRotatioToInt(double aValue) |
| | | { |
| | | public static int converRotatioToInt(double aValue) { |
| | | |
| | | return (int) (aValue * 360000.0); |
| | | } |
| | | |
| | | public static double converRotationToRadian(double aValue) |
| | | { |
| | | public static double converRotationToRadian(double aValue) { |
| | | |
| | | return aValue * Math.PI / 180; |
| | | } |
| | | |
| | | public static double converUnitToCoord(int aValue) |
| | | { |
| | | public static double converUnitToCoord(int aValue) { |
| | | double newVal; |
| | | |
| | | newVal = aValue / 1000.0; |
| | |
| | | return newVal; |
| | | } |
| | | |
| | | public static double converUnitToCoord(double aValue) |
| | | { |
| | | public static double converUnitToCoord(double aValue) { |
| | | double newVal; |
| | | |
| | | newVal = aValue / 1000.0; |
| | |
| | | return newVal; |
| | | } |
| | | |
| | | public static int converCoordToUnit(double aValue) |
| | | { |
| | | public static int converCoordToUnit(double aValue) { |
| | | double newVal = aValue; |
| | | |
| | | newVal -= 2147483.648; |
| | |
| | | return (int) newVal; |
| | | } |
| | | |
| | | public static Envelope converUnitToCoord(Envelope range) |
| | | { |
| | | if (range == null) |
| | | { |
| | | public static Envelope converUnitToCoord(Envelope range) { |
| | | if (range == null) { |
| | | return null; |
| | | } |
| | | |
| | |
| | | converUnitToCoord((int) range.getMinY()), converUnitToCoord((int) range.getMaxY())); |
| | | } |
| | | |
| | | public static Envelope converCoordToUnit(Envelope range) |
| | | { |
| | | if (range == null) |
| | | { |
| | | public static Envelope converCoordToUnit(Envelope range) { |
| | | if (range == null) { |
| | | return null; |
| | | } |
| | | |
| | |
| | | converCoordToUnit(range.getMinY()), converCoordToUnit(range.getMaxY())); |
| | | } |
| | | |
| | | public static long convertDGNToRAWIEEEDouble(byte[] org) |
| | | { |
| | | public static long convertDGNToRAWIEEEDouble(byte[] org) { |
| | | ByteBuffer buf = ByteBuffer.allocate(8); |
| | | buf.order(ByteOrder.LITTLE_ENDIAN); |
| | | buf.mark(); |
| | |
| | | int sign = (tmp[0] & 0x80000000); |
| | | exponent = (tmp[0] >>> 23) & 0x000000ff; |
| | | |
| | | if (exponent != 0) |
| | | { |
| | | if (exponent != 0) { |
| | | exponent = exponent - 129 + 1023; |
| | | } |
| | | |
| | |
| | | tmp[1] = tmp[1] >>> 3; |
| | | tmp[1] = (tmp[1] & 0x1fffffff) | (tmp[0] << 29); |
| | | |
| | | if (rndbits != 0) |
| | | { |
| | | if (rndbits != 0) { |
| | | tmp[1] = tmp[1] | 0x00000001; |
| | | } |
| | | |
| | |
| | | buf.get(tmpRaw); |
| | | buf.position(0); |
| | | buf.order(ByteOrder.LITTLE_ENDIAN); |
| | | for (int i = tmpRaw.length; i > 0; i--) |
| | | { |
| | | for (int i = tmpRaw.length; i > 0; i--) { |
| | | buf.put(tmpRaw[i - 1]); |
| | | } |
| | | buf.position(0); |
| | |
| | | return result; |
| | | } |
| | | |
| | | public static double convertDGNToIEEEDouble(byte[] src) |
| | | { |
| | | public static double convertDGNToIEEEDouble(byte[] src) { |
| | | return Double.longBitsToDouble(convertDGNToRAWIEEEDouble(src)); |
| | | } |
| | | |
| | | public static short[] convertIEEEDoubleToDGN(double src) |
| | | { |
| | | public static short[] convertIEEEDoubleToDGN(double src) { |
| | | long newVal = Double.doubleToLongBits(src); |
| | | |
| | | // uint[] tmp = new int[ 2 ]; |
| | |
| | | sign = tmp[0] & 0x80000000; |
| | | exponent = (tmp[0] >>> 20) & 0x07ff; |
| | | |
| | | if (exponent != 0) |
| | | { |
| | | if (exponent != 0) { |
| | | exponent = exponent - 1023 + 129; |
| | | } |
| | | |
| | | if (exponent > 255) |
| | | { |
| | | if (sign != 0) |
| | | { |
| | | if (exponent > 255) { |
| | | if (sign != 0) { |
| | | des[0] = -1; |
| | | } else |
| | | { |
| | | } else { |
| | | des[0] = 0x7fff; |
| | | } |
| | | |
| | |
| | | des[3] = -1; |
| | | |
| | | return des; |
| | | } else if ((exponent < 0) || ((exponent == 0) && (sign == 0))) |
| | | { |
| | | } else if ((exponent < 0) || ((exponent == 0) && (sign == 0))) { |
| | | des[0] = 0x0; |
| | | des[1] = 0x0; |
| | | des[2] = 0x0; |
| | | des[3] = 0x0; |
| | | |
| | | return des; |
| | | } else |
| | | { |
| | | } else { |
| | | tmp[0] = (tmp[0] << 3) | (tmp[1] >> 29); |
| | | tmp[0] = tmp[0] & 0x007fffff; |
| | | tmp[0] = tmp[0] | (exponent << 23) | sign; |
| | |
| | | return des; |
| | | } |
| | | |
| | | public static double getLength(double x1, double y1, double x2, double y2) |
| | | { |
| | | public static double getLength(double x1, double y1, double x2, double y2) { |
| | | double dx = x1 - x2; |
| | | double dy = y1 - y2; |
| | | |
| | |
| | | * formatting of -0.0f |
| | | * round up/down when last digits are 50000... |
| | | */ |
| | | public final class PrintfFormat |
| | | { |
| | | public final class PrintfFormat { |
| | | /** |
| | | * Vector of control strings and format literals. |
| | | */ |
| | |
| | | * string is null, zero length, or otherwise |
| | | * malformed. |
| | | */ |
| | | public PrintfFormat(String fmtArg) throws IllegalArgumentException |
| | | { |
| | | public PrintfFormat(String fmtArg) throws IllegalArgumentException { |
| | | this(Locale.getDefault(), fmtArg); |
| | | } |
| | | |
| | |
| | | * string is null, zero length, or otherwise |
| | | * malformed. |
| | | */ |
| | | public PrintfFormat(Locale locale, String fmtArg) throws IllegalArgumentException |
| | | { |
| | | public PrintfFormat(Locale locale, String fmtArg) throws IllegalArgumentException { |
| | | dfs = new DecimalFormatSymbols(locale); |
| | | |
| | | int ePos = 0; |
| | | ConversionSpecification sFmt = null; |
| | | String unCS = this.nonControl(fmtArg, 0); |
| | | |
| | | if (unCS != null) |
| | | { |
| | | if (unCS != null) { |
| | | sFmt = new ConversionSpecification(); |
| | | sFmt.setLiteral(unCS); |
| | | vFmt.addElement(sFmt); |
| | | } |
| | | |
| | | while ((cPos != -1) && (cPos < fmtArg.length())) |
| | | { |
| | | for (ePos = cPos + 1; ePos < fmtArg.length(); ePos++) |
| | | { |
| | | while ((cPos != -1) && (cPos < fmtArg.length())) { |
| | | for (ePos = cPos + 1; ePos < fmtArg.length(); ePos++) { |
| | | char c = 0; |
| | | |
| | | c = fmtArg.charAt(ePos); |
| | | |
| | | if (c == 'i') |
| | | { |
| | | if (c == 'i') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'd') |
| | | { |
| | | if (c == 'd') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'f') |
| | | { |
| | | if (c == 'f') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'g') |
| | | { |
| | | if (c == 'g') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'G') |
| | | { |
| | | if (c == 'G') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'o') |
| | | { |
| | | if (c == 'o') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'x') |
| | | { |
| | | if (c == 'x') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'X') |
| | | { |
| | | if (c == 'X') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'e') |
| | | { |
| | | if (c == 'e') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'E') |
| | | { |
| | | if (c == 'E') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 'c') |
| | | { |
| | | if (c == 'c') { |
| | | break; |
| | | } |
| | | |
| | | if (c == 's') |
| | | { |
| | | if (c == 's') { |
| | | break; |
| | | } |
| | | |
| | | if (c == '%') |
| | | { |
| | | if (c == '%') { |
| | | break; |
| | | } |
| | | } |
| | |
| | | vFmt.addElement(sFmt); |
| | | unCS = this.nonControl(fmtArg, ePos); |
| | | |
| | | if (unCS != null) |
| | | { |
| | | if (unCS != null) { |
| | | sFmt = new ConversionSpecification(); |
| | | sFmt.setLiteral(unCS); |
| | | vFmt.addElement(sFmt); |
| | |
| | | * @return the substring from the start position |
| | | * to the beginning of the control string. |
| | | */ |
| | | private String nonControl(String s, int start) |
| | | { |
| | | private String nonControl(String s, int start) { |
| | | String ret = ""; |
| | | |
| | | cPos = s.indexOf("%", start); |
| | | |
| | | if (cPos == -1) |
| | | { |
| | | if (cPos == -1) { |
| | | cPos = s.length(); |
| | | } |
| | | |
| | |
| | | * @param o The array of objects to format. |
| | | * @return The formatted String. |
| | | */ |
| | | public String sprintf(Object[] o) |
| | | { |
| | | public String sprintf(Object[] o) { |
| | | Enumeration e = vFmt.elements(); |
| | | ConversionSpecification cs = null; |
| | | char c = 0; |
| | | int i = 0; |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | while (e.hasMoreElements()) |
| | | { |
| | | while (e.hasMoreElements()) { |
| | | cs = (ConversionSpecification) e.nextElement(); |
| | | c = cs.getConversionCharacter(); |
| | | |
| | | if (c == '\0') |
| | | { |
| | | if (c == '\0') { |
| | | sb.append(cs.getLiteral()); |
| | | } else if (c == '%') |
| | | { |
| | | } else if (c == '%') { |
| | | sb.append("%"); |
| | | } else |
| | | { |
| | | if (cs.isPositionalSpecification()) |
| | | { |
| | | } else { |
| | | if (cs.isPositionalSpecification()) { |
| | | i = cs.getArgumentPosition() - 1; |
| | | |
| | | if (cs.isPositionalFieldWidth()) |
| | | { |
| | | if (cs.isPositionalFieldWidth()) { |
| | | int ifw = cs.getArgumentPositionForFieldWidth() - 1; |
| | | |
| | | cs.setFieldWidthWithArg(((Integer) o[ifw]).intValue()); |
| | | } |
| | | |
| | | if (cs.isPositionalPrecision()) |
| | | { |
| | | if (cs.isPositionalPrecision()) { |
| | | int ipr = cs.getArgumentPositionForPrecision() - 1; |
| | | |
| | | cs.setPrecisionWithArg(((Integer) o[ipr]).intValue()); |
| | | } |
| | | } else |
| | | { |
| | | if (cs.isVariableFieldWidth()) |
| | | { |
| | | } else { |
| | | if (cs.isVariableFieldWidth()) { |
| | | cs.setFieldWidthWithArg(((Integer) o[i]).intValue()); |
| | | i++; |
| | | } |
| | | |
| | | if (cs.isVariablePrecision()) |
| | | { |
| | | if (cs.isVariablePrecision()) { |
| | | cs.setPrecisionWithArg(((Integer) o[i]).intValue()); |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | if (o[i] instanceof Byte) |
| | | { |
| | | if (o[i] instanceof Byte) { |
| | | sb.append(cs.internalsprintf(((Byte) o[i]).byteValue())); |
| | | } else if (o[i] instanceof Short) |
| | | { |
| | | } else if (o[i] instanceof Short) { |
| | | sb.append(cs.internalsprintf(((Short) o[i]).shortValue())); |
| | | } else if (o[i] instanceof Integer) |
| | | { |
| | | } else if (o[i] instanceof Integer) { |
| | | sb.append(cs.internalsprintf(((Integer) o[i]).intValue())); |
| | | } else if (o[i] instanceof Long) |
| | | { |
| | | } else if (o[i] instanceof Long) { |
| | | sb.append(cs.internalsprintf(((Long) o[i]).longValue())); |
| | | } else if (o[i] instanceof Float) |
| | | { |
| | | } else if (o[i] instanceof Float) { |
| | | sb.append(cs.internalsprintf(((Float) o[i]).floatValue())); |
| | | } else if (o[i] instanceof Double) |
| | | { |
| | | } else if (o[i] instanceof Double) { |
| | | sb.append(cs.internalsprintf(((Double) o[i]).doubleValue())); |
| | | } else if (o[i] instanceof Character) |
| | | { |
| | | } else if (o[i] instanceof Character) { |
| | | sb.append(cs.internalsprintf(((Character) o[i]).charValue())); |
| | | } else if (o[i] instanceof String) |
| | | { |
| | | } else if (o[i] instanceof String) { |
| | | sb.append(cs.internalsprintf((String) o[i])); |
| | | } else |
| | | { |
| | | } else { |
| | | sb.append(cs.internalsprintf(o[i])); |
| | | } |
| | | |
| | | if (!cs.isPositionalSpecification()) |
| | | { |
| | | if (!cs.isPositionalSpecification()) { |
| | | i++; |
| | | } |
| | | } |
| | |
| | | * |
| | | * @return the formatted String. |
| | | */ |
| | | public String sprintf() |
| | | { |
| | | public String sprintf() { |
| | | Enumeration e = vFmt.elements(); |
| | | ConversionSpecification cs = null; |
| | | char c = 0; |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | while (e.hasMoreElements()) |
| | | { |
| | | while (e.hasMoreElements()) { |
| | | cs = (ConversionSpecification) e.nextElement(); |
| | | c = cs.getConversionCharacter(); |
| | | |
| | | if (c == '\0') |
| | | { |
| | | if (c == '\0') { |
| | | sb.append(cs.getLiteral()); |
| | | } else if (c == '%') |
| | | { |
| | | } else if (c == '%') { |
| | | sb.append("%"); |
| | | } |
| | | } |
| | |
| | | * conversion character is f, e, E, g, G, s, |
| | | * or S. |
| | | */ |
| | | public String sprintf(int x) throws IllegalArgumentException |
| | | { |
| | | public String sprintf(int x) throws IllegalArgumentException { |
| | | Enumeration e = vFmt.elements(); |
| | | ConversionSpecification cs = null; |
| | | char c = 0; |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | while (e.hasMoreElements()) |
| | | { |
| | | while (e.hasMoreElements()) { |
| | | cs = (ConversionSpecification) e.nextElement(); |
| | | c = cs.getConversionCharacter(); |
| | | |
| | | if (c == '\0') |
| | | { |
| | | if (c == '\0') { |
| | | sb.append(cs.getLiteral()); |
| | | } else if (c == '%') |
| | | { |
| | | } else if (c == '%') { |
| | | sb.append("%"); |
| | | } else |
| | | { |
| | | } else { |
| | | sb.append(cs.internalsprintf(x)); |
| | | } |
| | | } |
| | |
| | | * conversion character is f, e, E, g, G, s, |
| | | * or S. |
| | | */ |
| | | public String sprintf(long x) throws IllegalArgumentException |
| | | { |
| | | public String sprintf(long x) throws IllegalArgumentException { |
| | | Enumeration e = vFmt.elements(); |
| | | ConversionSpecification cs = null; |
| | | char c = 0; |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | while (e.hasMoreElements()) |
| | | { |
| | | while (e.hasMoreElements()) { |
| | | cs = (ConversionSpecification) e.nextElement(); |
| | | c = cs.getConversionCharacter(); |
| | | |
| | | if (c == '\0') |
| | | { |
| | | if (c == '\0') { |
| | | sb.append(cs.getLiteral()); |
| | | } else if (c == '%') |
| | | { |
| | | } else if (c == '%') { |
| | | sb.append("%"); |
| | | } else |
| | | { |
| | | } else { |
| | | sb.append(cs.internalsprintf(x)); |
| | | } |
| | | } |
| | |
| | | * conversion character is c, C, s, S, |
| | | * d, d, x, X, or o. |
| | | */ |
| | | public String sprintf(double x) throws IllegalArgumentException |
| | | { |
| | | public String sprintf(double x) throws IllegalArgumentException { |
| | | Enumeration e = vFmt.elements(); |
| | | ConversionSpecification cs = null; |
| | | char c = 0; |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | while (e.hasMoreElements()) |
| | | { |
| | | while (e.hasMoreElements()) { |
| | | cs = (ConversionSpecification) e.nextElement(); |
| | | c = cs.getConversionCharacter(); |
| | | |
| | | if (c == '\0') |
| | | { |
| | | if (c == '\0') { |
| | | sb.append(cs.getLiteral()); |
| | | } else if (c == '%') |
| | | { |
| | | } else if (c == '%') { |
| | | sb.append("%"); |
| | | } else |
| | | { |
| | | } else { |
| | | sb.append(cs.internalsprintf(x)); |
| | | } |
| | | } |
| | |
| | | * @throws IllegalArgumentException if the |
| | | * conversion character is neither s nor S. |
| | | */ |
| | | public String sprintf(String x) throws IllegalArgumentException |
| | | { |
| | | public String sprintf(String x) throws IllegalArgumentException { |
| | | Enumeration e = vFmt.elements(); |
| | | ConversionSpecification cs = null; |
| | | char c = 0; |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | while (e.hasMoreElements()) |
| | | { |
| | | while (e.hasMoreElements()) { |
| | | cs = (ConversionSpecification) e.nextElement(); |
| | | c = cs.getConversionCharacter(); |
| | | |
| | | if (c == '\0') |
| | | { |
| | | if (c == '\0') { |
| | | sb.append(cs.getLiteral()); |
| | | } else if (c == '%') |
| | | { |
| | | } else if (c == '%') { |
| | | sb.append("%"); |
| | | } else |
| | | { |
| | | } else { |
| | | sb.append(cs.internalsprintf(x)); |
| | | } |
| | | } |
| | |
| | | * conversion character is inappropriate for |
| | | * formatting an unwrapped value. |
| | | */ |
| | | public String sprintf(Object x) throws IllegalArgumentException |
| | | { |
| | | public String sprintf(Object x) throws IllegalArgumentException { |
| | | Enumeration e = vFmt.elements(); |
| | | ConversionSpecification cs = null; |
| | | char c = 0; |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | while (e.hasMoreElements()) |
| | | { |
| | | while (e.hasMoreElements()) { |
| | | cs = (ConversionSpecification) e.nextElement(); |
| | | c = cs.getConversionCharacter(); |
| | | |
| | | if (c == '\0') |
| | | { |
| | | if (c == '\0') { |
| | | sb.append(cs.getLiteral()); |
| | | } else if (c == '%') |
| | | { |
| | | } else if (c == '%') { |
| | | sb.append("%"); |
| | | } else |
| | | { |
| | | if (x instanceof Byte) |
| | | { |
| | | } else { |
| | | if (x instanceof Byte) { |
| | | sb.append(cs.internalsprintf(((Byte) x).byteValue())); |
| | | } else if (x instanceof Short) |
| | | { |
| | | } else if (x instanceof Short) { |
| | | sb.append(cs.internalsprintf(((Short) x).shortValue())); |
| | | } else if (x instanceof Integer) |
| | | { |
| | | } else if (x instanceof Integer) { |
| | | sb.append(cs.internalsprintf(((Integer) x).intValue())); |
| | | } else if (x instanceof Long) |
| | | { |
| | | } else if (x instanceof Long) { |
| | | sb.append(cs.internalsprintf(((Long) x).longValue())); |
| | | } else if (x instanceof Float) |
| | | { |
| | | } else if (x instanceof Float) { |
| | | sb.append(cs.internalsprintf(((Float) x).floatValue())); |
| | | } else if (x instanceof Double) |
| | | { |
| | | } else if (x instanceof Double) { |
| | | sb.append(cs.internalsprintf(((Double) x).doubleValue())); |
| | | } else if (x instanceof Character) |
| | | { |
| | | } else if (x instanceof Character) { |
| | | sb.append(cs.internalsprintf(((Character) x).charValue())); |
| | | } else if (x instanceof String) |
| | | { |
| | | } else if (x instanceof String) { |
| | | sb.append(cs.internalsprintf((String) x)); |
| | | } else |
| | | { |
| | | } else { |
| | | sb.append(cs.internalsprintf(x)); |
| | | } |
| | | } |
| | |
| | | * optional L does not imply conversion to a long |
| | | * long double. |
| | | */ |
| | | private class ConversionSpecification |
| | | { |
| | | private class ConversionSpecification { |
| | | /** |
| | | * Default precision. |
| | | */ |
| | |
| | | * Constructor. Used to prepare an instance |
| | | * to hold a literal, not a control string. |
| | | */ |
| | | ConversionSpecification() |
| | | { |
| | | ConversionSpecification() { |
| | | } |
| | | |
| | | /** |
| | |
| | | * input string is null, zero length, or |
| | | * otherwise malformed. |
| | | */ |
| | | ConversionSpecification(String fmtArg) throws IllegalArgumentException |
| | | { |
| | | if (fmtArg == null) |
| | | { |
| | | ConversionSpecification(String fmtArg) throws IllegalArgumentException { |
| | | if (fmtArg == null) { |
| | | throw new NullPointerException(); |
| | | } |
| | | |
| | | if (fmtArg.length() == 0) |
| | | { |
| | | if (fmtArg.length() == 0) { |
| | | throw new IllegalArgumentException("Control strings must have positive" + " lengths."); |
| | | } |
| | | |
| | | if (fmtArg.charAt(0) == '%') |
| | | { |
| | | if (fmtArg.charAt(0) == '%') { |
| | | fmt = fmtArg; |
| | | pos = 1; |
| | | setArgPosition(); |
| | |
| | | setPrecision(); |
| | | setOptionalHL(); |
| | | |
| | | if (setConversionCharacter()) |
| | | { |
| | | if (pos == fmtArg.length()) |
| | | { |
| | | if (leadingZeros && leftJustify) |
| | | { |
| | | if (setConversionCharacter()) { |
| | | if (pos == fmtArg.length()) { |
| | | if (leadingZeros && leftJustify) { |
| | | leadingZeros = false; |
| | | } |
| | | |
| | | if (precisionSet && leadingZeros) |
| | | { |
| | | if (precisionSet && leadingZeros) { |
| | | if ((conversionCharacter == 'd') || (conversionCharacter == 'i') || (conversionCharacter == 'o') |
| | | || (conversionCharacter == 'x')) |
| | | { |
| | | || (conversionCharacter == 'x')) { |
| | | leadingZeros = false; |
| | | } |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | throw new IllegalArgumentException("Malformed conversion specification=" + fmtArg); |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | throw new IllegalArgumentException("Malformed conversion specification=" + fmtArg); |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | throw new IllegalArgumentException("Control strings must begin with %."); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @param s the String to store. |
| | | */ |
| | | void setLiteral(String s) |
| | | { |
| | | void setLiteral(String s) { |
| | | fmt = s; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return s the stored String. |
| | | */ |
| | | String getLiteral() |
| | | { |
| | | String getLiteral() { |
| | | StringBuilder sb = new StringBuilder(); |
| | | int i = 0; |
| | | |
| | | while (i < fmt.length()) |
| | | { |
| | | if (fmt.charAt(i) == '\\') |
| | | { |
| | | while (i < fmt.length()) { |
| | | if (fmt.charAt(i) == '\\') { |
| | | i++; |
| | | |
| | | if (i < fmt.length()) |
| | | { |
| | | if (i < fmt.length()) { |
| | | char c = fmt.charAt(i); |
| | | |
| | | switch (c) |
| | | { |
| | | switch (c) { |
| | | case 'a': |
| | | sb.append((char) 0x07); |
| | | |
| | |
| | | } |
| | | |
| | | i++; |
| | | } else |
| | | { |
| | | } else { |
| | | sb.append('\\'); |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | i++; |
| | | } |
| | | } |
| | |
| | | * |
| | | * @return the conversion character. |
| | | */ |
| | | char getConversionCharacter() |
| | | { |
| | | char getConversionCharacter() { |
| | | return conversionCharacter; |
| | | } |
| | | |
| | |
| | | * uses an * field width; otherwise |
| | | * <code>false</code>. |
| | | */ |
| | | boolean isVariableFieldWidth() |
| | | { |
| | | boolean isVariableFieldWidth() { |
| | | return variableFieldWidth; |
| | | } |
| | | |
| | |
| | | * |
| | | * @param fw the field width. |
| | | */ |
| | | void setFieldWidthWithArg(int fw) |
| | | { |
| | | if (fw < 0) |
| | | { |
| | | void setFieldWidthWithArg(int fw) { |
| | | if (fw < 0) { |
| | | leftJustify = true; |
| | | } |
| | | |
| | |
| | | * uses an * precision; otherwise |
| | | * <code>false</code>. |
| | | */ |
| | | boolean isVariablePrecision() |
| | | { |
| | | boolean isVariablePrecision() { |
| | | return variablePrecision; |
| | | } |
| | | |
| | |
| | | * |
| | | * @param pr the precision. |
| | | */ |
| | | void setPrecisionWithArg(int pr) |
| | | { |
| | | void setPrecisionWithArg(int pr) { |
| | | precisionSet = true; |
| | | precision = Math.max(pr, 0); |
| | | } |
| | |
| | | * @throws IllegalArgumentException if the |
| | | * conversion character is f, e, E, g, or G. |
| | | */ |
| | | String internalsprintf(int s) throws IllegalArgumentException |
| | | { |
| | | String internalsprintf(int s) throws IllegalArgumentException { |
| | | String s2 = ""; |
| | | |
| | | switch (conversionCharacter) |
| | | { |
| | | switch (conversionCharacter) { |
| | | case 'd': |
| | | case 'i': |
| | | if (optionalh) |
| | | { |
| | | if (optionalh) { |
| | | s2 = printDFormat((short) s); |
| | | } else if (optionall) |
| | | { |
| | | } else if (optionall) { |
| | | s2 = printDFormat((long) s); |
| | | } else |
| | | { |
| | | } else { |
| | | s2 = printDFormat(s); |
| | | } |
| | | |
| | |
| | | |
| | | case 'x': |
| | | case 'X': |
| | | if (optionalh) |
| | | { |
| | | if (optionalh) { |
| | | s2 = printXFormat((short) s); |
| | | } else if (optionall) |
| | | { |
| | | } else if (optionall) { |
| | | s2 = printXFormat((long) s); |
| | | } else |
| | | { |
| | | } else { |
| | | s2 = printXFormat(s); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case 'o': |
| | | if (optionalh) |
| | | { |
| | | if (optionalh) { |
| | | s2 = printOFormat((short) s); |
| | | } else if (optionall) |
| | | { |
| | | } else if (optionall) { |
| | | s2 = printOFormat((long) s); |
| | | } else |
| | | { |
| | | } else { |
| | | s2 = printOFormat(s); |
| | | } |
| | | |
| | |
| | | * @throws IllegalArgumentException if the |
| | | * conversion character is f, e, E, g, or G. |
| | | */ |
| | | String internalsprintf(long s) throws IllegalArgumentException |
| | | { |
| | | String internalsprintf(long s) throws IllegalArgumentException { |
| | | String s2 = ""; |
| | | |
| | | switch (conversionCharacter) |
| | | { |
| | | switch (conversionCharacter) { |
| | | case 'd': |
| | | case 'i': |
| | | if (optionalh) |
| | | { |
| | | if (optionalh) { |
| | | s2 = printDFormat((short) s); |
| | | } else if (optionall) |
| | | { |
| | | } else if (optionall) { |
| | | s2 = printDFormat(s); |
| | | } else |
| | | { |
| | | } else { |
| | | s2 = printDFormat((int) s); |
| | | } |
| | | |
| | |
| | | |
| | | case 'x': |
| | | case 'X': |
| | | if (optionalh) |
| | | { |
| | | if (optionalh) { |
| | | s2 = printXFormat((short) s); |
| | | } else if (optionall) |
| | | { |
| | | } else if (optionall) { |
| | | s2 = printXFormat(s); |
| | | } else |
| | | { |
| | | } else { |
| | | s2 = printXFormat((int) s); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case 'o': |
| | | if (optionalh) |
| | | { |
| | | if (optionalh) { |
| | | s2 = printOFormat((short) s); |
| | | } else if (optionall) |
| | | { |
| | | } else if (optionall) { |
| | | s2 = printOFormat(s); |
| | | } else |
| | | { |
| | | } else { |
| | | s2 = printOFormat((int) s); |
| | | } |
| | | |
| | |
| | | * conversion character is c, C, s, S, i, d, |
| | | * x, X, or o. |
| | | */ |
| | | String internalsprintf(double s) throws IllegalArgumentException |
| | | { |
| | | String internalsprintf(double s) throws IllegalArgumentException { |
| | | String s2 = ""; |
| | | |
| | | switch (conversionCharacter) |
| | | { |
| | | switch (conversionCharacter) { |
| | | case 'f': |
| | | s2 = printFFormat(s); |
| | | |
| | |
| | | * @throws IllegalArgumentException if the |
| | | * conversion character is neither s nor S. |
| | | */ |
| | | String internalsprintf(String s) throws IllegalArgumentException |
| | | { |
| | | String internalsprintf(String s) throws IllegalArgumentException { |
| | | String s2 = ""; |
| | | |
| | | if ((conversionCharacter == 's') || (conversionCharacter == 'S')) |
| | | { |
| | | if ((conversionCharacter == 's') || (conversionCharacter == 'S')) { |
| | | s2 = printSFormat(s); |
| | | } else |
| | | { |
| | | } else { |
| | | throw new IllegalArgumentException("Cannot " + "format a String with a format using a " + conversionCharacter |
| | | + " conversion character."); |
| | | } |
| | |
| | | * @throws IllegalArgumentException if the |
| | | * conversion character is neither s nor S. |
| | | */ |
| | | String internalsprintf(Object s) |
| | | { |
| | | String internalsprintf(Object s) { |
| | | String s2 = ""; |
| | | |
| | | if ((conversionCharacter == 's') || (conversionCharacter == 'S')) |
| | | { |
| | | if ((conversionCharacter == 's') || (conversionCharacter == 'S')) { |
| | | s2 = printSFormat(s.toString()); |
| | | } else |
| | | { |
| | | } else { |
| | | throw new IllegalArgumentException("Cannot format a String with a format using" + " a " + conversionCharacter |
| | | + " conversion character."); |
| | | } |
| | |
| | | * to appear after the radix character. Padding is |
| | | * with trailing 0s. |
| | | */ |
| | | private char[] fFormatDigits(double x) |
| | | { |
| | | private char[] fFormatDigits(double x) { |
| | | // int defaultDigits=6; |
| | | String sx, sxOut; |
| | | int i, j, k; |
| | |
| | | int expon = 0; |
| | | boolean minusSign = false; |
| | | |
| | | if (x > 0.0) |
| | | { |
| | | if (x > 0.0) { |
| | | sx = Double.toString(x); |
| | | } else if (x < 0.0) |
| | | { |
| | | } else if (x < 0.0) { |
| | | sx = Double.toString(-x); |
| | | minusSign = true; |
| | | } else |
| | | { |
| | | } else { |
| | | sx = Double.toString(x); |
| | | |
| | | if (sx.charAt(0) == '-') |
| | | { |
| | | if (sx.charAt(0) == '-') { |
| | | minusSign = true; |
| | | sx = sx.substring(1); |
| | | } |
| | |
| | | int ePos = sx.indexOf('E'); |
| | | int rPos = sx.indexOf('.'); |
| | | |
| | | if (rPos != -1) |
| | | { |
| | | if (rPos != -1) { |
| | | n1In = rPos; |
| | | } else if (ePos != -1) |
| | | { |
| | | } else if (ePos != -1) { |
| | | n1In = ePos; |
| | | } else |
| | | { |
| | | } else { |
| | | n1In = sx.length(); |
| | | } |
| | | |
| | | if (rPos != -1) |
| | | { |
| | | if (ePos != -1) |
| | | { |
| | | if (rPos != -1) { |
| | | if (ePos != -1) { |
| | | n2In = ePos - rPos - 1; |
| | | } else |
| | | { |
| | | } else { |
| | | n2In = sx.length() - rPos - 1; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | n2In = 0; |
| | | } |
| | | |
| | | if (ePos != -1) |
| | | { |
| | | if (ePos != -1) { |
| | | int ie = ePos + 1; |
| | | |
| | | expon = 0; |
| | | |
| | | if (sx.charAt(ie) == '-') |
| | | { |
| | | for (++ie; ie < sx.length(); ie++) |
| | | { |
| | | if (sx.charAt(ie) != '0') |
| | | { |
| | | if (sx.charAt(ie) == '-') { |
| | | for (++ie; ie < sx.length(); ie++) { |
| | | if (sx.charAt(ie) != '0') { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (ie < sx.length()) |
| | | { |
| | | if (ie < sx.length()) { |
| | | expon = -Integer.parseInt(sx.substring(ie)); |
| | | } |
| | | } else |
| | | { |
| | | if (sx.charAt(ie) == '+') |
| | | { |
| | | } else { |
| | | if (sx.charAt(ie) == '+') { |
| | | ++ie; |
| | | } |
| | | |
| | | for (; ie < sx.length(); ie++) |
| | | { |
| | | if (sx.charAt(ie) != '0') |
| | | { |
| | | for (; ie < sx.length(); ie++) { |
| | | if (sx.charAt(ie) != '0') { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (ie < sx.length()) |
| | | { |
| | | if (ie < sx.length()) { |
| | | expon = Integer.parseInt(sx.substring(ie)); |
| | | } |
| | | } |
| | |
| | | |
| | | int p; |
| | | |
| | | if (precisionSet) |
| | | { |
| | | if (precisionSet) { |
| | | p = precision; |
| | | } else |
| | | { |
| | | } else { |
| | | p = defaultDigits - 1; |
| | | } |
| | | |
| | |
| | | char[] ca2 = new char[n1In + n2In]; |
| | | char[] ca3, ca4, ca5; |
| | | |
| | | for (j = 0; j < n1In; j++) |
| | | { |
| | | for (j = 0; j < n1In; j++) { |
| | | ca2[j] = ca1[j]; |
| | | } |
| | | |
| | | i = j + 1; |
| | | |
| | | for (k = 0; k < n2In; j++, i++, k++) |
| | | { |
| | | for (k = 0; k < n2In; j++, i++, k++) { |
| | | ca2[j] = ca1[i]; |
| | | } |
| | | |
| | | if (n1In + expon <= 0) |
| | | { |
| | | if (n1In + expon <= 0) { |
| | | ca3 = new char[-expon + n2In]; |
| | | |
| | | for (j = 0, k = 0; k < (-n1In - expon); k++, j++) |
| | | { |
| | | for (j = 0, k = 0; k < (-n1In - expon); k++, j++) { |
| | | ca3[j] = '0'; |
| | | } |
| | | |
| | | for (i = 0; i < (n1In + n2In); i++, j++) |
| | | { |
| | | for (i = 0; i < (n1In + n2In); i++, j++) { |
| | | ca3[j] = ca2[i]; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | ca3 = ca2; |
| | | } |
| | | |
| | | boolean carry = false; |
| | | |
| | | if (p < -expon + n2In) |
| | | { |
| | | if (expon < 0) |
| | | { |
| | | if (p < -expon + n2In) { |
| | | if (expon < 0) { |
| | | i = p; |
| | | } else |
| | | { |
| | | } else { |
| | | i = p + n1In; |
| | | } |
| | | |
| | | carry = checkForCarry(ca3, i); |
| | | |
| | | if (carry) |
| | | { |
| | | if (carry) { |
| | | carry = startSymbolicCarry(ca3, i - 1, 0); |
| | | } |
| | | } |
| | | |
| | | if (n1In + expon <= 0) |
| | | { |
| | | if (n1In + expon <= 0) { |
| | | ca4 = new char[2 + p]; |
| | | |
| | | if (!carry) |
| | | { |
| | | if (!carry) { |
| | | ca4[0] = '0'; |
| | | } else |
| | | { |
| | | } else { |
| | | ca4[0] = '1'; |
| | | } |
| | | |
| | | if (alternateForm || !precisionSet || (precision != 0)) |
| | | { |
| | | if (alternateForm || !precisionSet || (precision != 0)) { |
| | | ca4[1] = '.'; |
| | | |
| | | for (i = 0, j = 2; i < Math.min(p, ca3.length); i++, j++) |
| | | { |
| | | for (i = 0, j = 2; i < Math.min(p, ca3.length); i++, j++) { |
| | | ca4[j] = ca3[i]; |
| | | } |
| | | |
| | | for (; j < ca4.length; j++) |
| | | { |
| | | for (; j < ca4.length; j++) { |
| | | ca4[j] = '0'; |
| | | } |
| | | } |
| | | } else |
| | | { |
| | | if (!carry) |
| | | { |
| | | if (alternateForm || !precisionSet || (precision != 0)) |
| | | { |
| | | } else { |
| | | if (!carry) { |
| | | if (alternateForm || !precisionSet || (precision != 0)) { |
| | | ca4 = new char[n1In + expon + p + 1]; |
| | | } else |
| | | { |
| | | } else { |
| | | ca4 = new char[n1In + expon]; |
| | | } |
| | | |
| | | j = 0; |
| | | } else |
| | | { |
| | | if (alternateForm || !precisionSet || (precision != 0)) |
| | | { |
| | | } else { |
| | | if (alternateForm || !precisionSet || (precision != 0)) { |
| | | ca4 = new char[n1In + expon + p + 2]; |
| | | } else |
| | | { |
| | | } else { |
| | | ca4 = new char[n1In + expon + 1]; |
| | | } |
| | | |
| | |
| | | j = 1; |
| | | } |
| | | |
| | | for (i = 0; i < Math.min(n1In + expon, ca3.length); i++, j++) |
| | | { |
| | | for (i = 0; i < Math.min(n1In + expon, ca3.length); i++, j++) { |
| | | ca4[j] = ca3[i]; |
| | | } |
| | | |
| | | for (; i < n1In + expon; i++, j++) |
| | | { |
| | | for (; i < n1In + expon; i++, j++) { |
| | | ca4[j] = '0'; |
| | | } |
| | | |
| | | if (alternateForm || !precisionSet || (precision != 0)) |
| | | { |
| | | if (alternateForm || !precisionSet || (precision != 0)) { |
| | | ca4[j] = '.'; |
| | | j++; |
| | | |
| | | for (k = 0; (i < ca3.length) && (k < p); i++, j++, k++) |
| | | { |
| | | for (k = 0; (i < ca3.length) && (k < p); i++, j++, k++) { |
| | | ca4[j] = ca3[i]; |
| | | } |
| | | |
| | | for (; j < ca4.length; j++) |
| | | { |
| | | for (; j < ca4.length; j++) { |
| | | ca4[j] = '0'; |
| | | } |
| | | } |
| | |
| | | |
| | | int nZeros = 0; |
| | | |
| | | if (!leftJustify && leadingZeros) |
| | | { |
| | | if (!leftJustify && leadingZeros) { |
| | | int xThousands = 0; |
| | | |
| | | if (thousands) |
| | | { |
| | | if (thousands) { |
| | | int xlead = 0; |
| | | |
| | | if ((ca4[0] == '+') || (ca4[0] == '-') || (ca4[0] == ' ')) |
| | | { |
| | | if ((ca4[0] == '+') || (ca4[0] == '-') || (ca4[0] == ' ')) { |
| | | xlead = 1; |
| | | } |
| | | |
| | | int xdp = xlead; |
| | | |
| | | for (; xdp < ca4.length; xdp++) |
| | | { |
| | | if (ca4[xdp] == '.') |
| | | { |
| | | for (; xdp < ca4.length; xdp++) { |
| | | if (ca4[xdp] == '.') { |
| | | break; |
| | | } |
| | | } |
| | |
| | | xThousands = (xdp - xlead) / 3; |
| | | } |
| | | |
| | | if (fieldWidthSet) |
| | | { |
| | | if (fieldWidthSet) { |
| | | nZeros = fieldWidth - ca4.length; |
| | | } |
| | | |
| | | if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) |
| | | { |
| | | if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) { |
| | | nZeros--; |
| | | } |
| | | |
| | | nZeros -= xThousands; |
| | | |
| | | if (nZeros < 0) |
| | | { |
| | | if (nZeros < 0) { |
| | | nZeros = 0; |
| | | } |
| | | } |
| | | |
| | | j = 0; |
| | | |
| | | if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) |
| | | { |
| | | if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) { |
| | | ca5 = new char[ca4.length + nZeros + 1]; |
| | | j++; |
| | | } else |
| | | { |
| | | } else { |
| | | ca5 = new char[ca4.length + nZeros]; |
| | | } |
| | | |
| | | if (!minusSign) |
| | | { |
| | | if (leadingSign) |
| | | { |
| | | if (!minusSign) { |
| | | if (leadingSign) { |
| | | ca5[0] = '+'; |
| | | } |
| | | |
| | | if (leadingSpace) |
| | | { |
| | | if (leadingSpace) { |
| | | ca5[0] = ' '; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | ca5[0] = '-'; |
| | | } |
| | | |
| | | for (i = 0; i < nZeros; i++, j++) |
| | | { |
| | | for (i = 0; i < nZeros; i++, j++) { |
| | | ca5[j] = '0'; |
| | | } |
| | | |
| | | for (i = 0; i < ca4.length; i++, j++) |
| | | { |
| | | for (i = 0; i < ca4.length; i++, j++) { |
| | | ca5[j] = ca4[i]; |
| | | } |
| | | |
| | | int lead = 0; |
| | | |
| | | if ((ca5[0] == '+') || (ca5[0] == '-') || (ca5[0] == ' ')) |
| | | { |
| | | if ((ca5[0] == '+') || (ca5[0] == '-') || (ca5[0] == ' ')) { |
| | | lead = 1; |
| | | } |
| | | |
| | | int dp = lead; |
| | | |
| | | for (; dp < ca5.length; dp++) |
| | | { |
| | | if (ca5[dp] == '.') |
| | | { |
| | | for (; dp < ca5.length; dp++) { |
| | | if (ca5[dp] == '.') { |
| | | break; |
| | | } |
| | | } |
| | |
| | | int nThousands = (dp - lead) / 3; |
| | | |
| | | // Localize the decimal point. |
| | | if (dp < ca5.length) |
| | | { |
| | | if (dp < ca5.length) { |
| | | ca5[dp] = dfs.getDecimalSeparator(); |
| | | } |
| | | |
| | | char[] ca6 = ca5; |
| | | |
| | | if (thousands && (nThousands > 0)) |
| | | { |
| | | if (thousands && (nThousands > 0)) { |
| | | ca6 = new char[ca5.length + nThousands + lead]; |
| | | ca6[0] = ca5[0]; |
| | | |
| | | for (i = lead, k = lead; i < dp; i++) |
| | | { |
| | | if ((i > 0) && (dp - i) % 3 == 0) |
| | | { |
| | | for (i = lead, k = lead; i < dp; i++) { |
| | | if ((i > 0) && (dp - i) % 3 == 0) { |
| | | // ca6[k]=','; |
| | | ca6[k] = dfs.getGroupingSeparator(); |
| | | ca6[k + 1] = ca5[i]; |
| | | k += 2; |
| | | } else |
| | | { |
| | | } else { |
| | | ca6[k] = ca5[i]; |
| | | k++; |
| | | } |
| | | } |
| | | |
| | | for (; i < ca5.length; i++, k++) |
| | | { |
| | | for (; i < ca5.length; i++, k++) { |
| | | ca6[k] = ca5[i]; |
| | | } |
| | | } |
| | |
| | | * @param x the double value to be formatted. |
| | | * @return the converted double value. |
| | | */ |
| | | private String fFormatString(double x) |
| | | { |
| | | private String fFormatString(double x) { |
| | | boolean noDigits = false; |
| | | char[] ca6, ca7; |
| | | |
| | | if (Double.isInfinite(x)) |
| | | { |
| | | if (x == Double.POSITIVE_INFINITY) |
| | | { |
| | | if (leadingSign) |
| | | { |
| | | if (Double.isInfinite(x)) { |
| | | if (x == Double.POSITIVE_INFINITY) { |
| | | if (leadingSign) { |
| | | ca6 = "+Inf".toCharArray(); |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | ca6 = " Inf".toCharArray(); |
| | | } else |
| | | { |
| | | } else { |
| | | ca6 = "Inf".toCharArray(); |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | ca6 = "-Inf".toCharArray(); |
| | | } |
| | | |
| | | noDigits = true; |
| | | } else if (Double.isNaN(x)) |
| | | { |
| | | if (leadingSign) |
| | | { |
| | | } else if (Double.isNaN(x)) { |
| | | if (leadingSign) { |
| | | ca6 = "+NaN".toCharArray(); |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | ca6 = " NaN".toCharArray(); |
| | | } else |
| | | { |
| | | } else { |
| | | ca6 = "NaN".toCharArray(); |
| | | } |
| | | |
| | | noDigits = true; |
| | | } else |
| | | { |
| | | } else { |
| | | ca6 = fFormatDigits(x); |
| | | } |
| | | |
| | |
| | | * L does not imply conversion to a long long |
| | | * double. |
| | | */ |
| | | private char[] eFormatDigits(double x, char eChar) |
| | | { |
| | | private char[] eFormatDigits(double x, char eChar) { |
| | | char[] ca1, ca2, ca3; |
| | | |
| | | // int defaultDigits=6; |
| | |
| | | int ePos, rPos, eSize; |
| | | boolean minusSign = false; |
| | | |
| | | if (x > 0.0) |
| | | { |
| | | if (x > 0.0) { |
| | | sx = Double.toString(x); |
| | | } else if (x < 0.0) |
| | | { |
| | | } else if (x < 0.0) { |
| | | sx = Double.toString(-x); |
| | | minusSign = true; |
| | | } else |
| | | { |
| | | } else { |
| | | sx = Double.toString(x); |
| | | |
| | | if (sx.charAt(0) == '-') |
| | | { |
| | | if (sx.charAt(0) == '-') { |
| | | minusSign = true; |
| | | sx = sx.substring(1); |
| | | } |
| | |
| | | |
| | | ePos = sx.indexOf('E'); |
| | | |
| | | if (ePos == -1) |
| | | { |
| | | if (ePos == -1) { |
| | | ePos = sx.indexOf('e'); |
| | | } |
| | | |
| | | rPos = sx.indexOf('.'); |
| | | |
| | | if (rPos != -1) |
| | | { |
| | | if (rPos != -1) { |
| | | n1In = rPos; |
| | | } else if (ePos != -1) |
| | | { |
| | | } else if (ePos != -1) { |
| | | n1In = ePos; |
| | | } else |
| | | { |
| | | } else { |
| | | n1In = sx.length(); |
| | | } |
| | | |
| | | if (rPos != -1) |
| | | { |
| | | if (ePos != -1) |
| | | { |
| | | if (rPos != -1) { |
| | | if (ePos != -1) { |
| | | n2In = ePos - rPos - 1; |
| | | } else |
| | | { |
| | | } else { |
| | | n2In = sx.length() - rPos - 1; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | n2In = 0; |
| | | } |
| | | |
| | | if (ePos != -1) |
| | | { |
| | | if (ePos != -1) { |
| | | int ie = ePos + 1; |
| | | |
| | | expon = 0; |
| | | |
| | | if (sx.charAt(ie) == '-') |
| | | { |
| | | for (++ie; ie < sx.length(); ie++) |
| | | { |
| | | if (sx.charAt(ie) != '0') |
| | | { |
| | | if (sx.charAt(ie) == '-') { |
| | | for (++ie; ie < sx.length(); ie++) { |
| | | if (sx.charAt(ie) != '0') { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (ie < sx.length()) |
| | | { |
| | | if (ie < sx.length()) { |
| | | expon = -Integer.parseInt(sx.substring(ie)); |
| | | } |
| | | } else |
| | | { |
| | | if (sx.charAt(ie) == '+') |
| | | { |
| | | } else { |
| | | if (sx.charAt(ie) == '+') { |
| | | ++ie; |
| | | } |
| | | |
| | | for (; ie < sx.length(); ie++) |
| | | { |
| | | if (sx.charAt(ie) != '0') |
| | | { |
| | | for (; ie < sx.length(); ie++) { |
| | | if (sx.charAt(ie) != '0') { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (ie < sx.length()) |
| | | { |
| | | if (ie < sx.length()) { |
| | | expon = Integer.parseInt(sx.substring(ie)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (rPos != -1) |
| | | { |
| | | if (rPos != -1) { |
| | | expon += rPos - 1; |
| | | } |
| | | |
| | | if (precisionSet) |
| | | { |
| | | if (precisionSet) { |
| | | p = precision; |
| | | } else |
| | | { |
| | | } else { |
| | | p = defaultDigits - 1; |
| | | } |
| | | |
| | | if ((rPos != -1) && (ePos != -1)) |
| | | { |
| | | if ((rPos != -1) && (ePos != -1)) { |
| | | ca1 = (sx.substring(0, rPos) + sx.substring(rPos + 1, ePos)).toCharArray(); |
| | | } else if (rPos != -1) |
| | | { |
| | | } else if (rPos != -1) { |
| | | ca1 = (sx.substring(0, rPos) + sx.substring(rPos + 1)).toCharArray(); |
| | | } else if (ePos != -1) |
| | | { |
| | | } else if (ePos != -1) { |
| | | ca1 = sx.substring(0, ePos).toCharArray(); |
| | | } else |
| | | { |
| | | } else { |
| | | ca1 = sx.toCharArray(); |
| | | } |
| | | |
| | | boolean carry = false; |
| | | int i0 = 0; |
| | | |
| | | if (ca1[0] != '0') |
| | | { |
| | | if (ca1[0] != '0') { |
| | | i0 = 0; |
| | | } else |
| | | { |
| | | for (i0 = 0; i0 < ca1.length; i0++) |
| | | { |
| | | if (ca1[i0] != '0') |
| | | { |
| | | } else { |
| | | for (i0 = 0; i0 < ca1.length; i0++) { |
| | | if (ca1[i0] != '0') { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (i0 + p < ca1.length - 1) |
| | | { |
| | | if (i0 + p < ca1.length - 1) { |
| | | carry = checkForCarry(ca1, i0 + p + 1); |
| | | |
| | | if (carry) |
| | | { |
| | | if (carry) { |
| | | carry = startSymbolicCarry(ca1, i0 + p, i0); |
| | | } |
| | | |
| | | if (carry) |
| | | { |
| | | if (carry) { |
| | | ca2 = new char[i0 + p + 1]; |
| | | ca2[i0] = '1'; |
| | | |
| | | for (j = 0; j < i0; j++) |
| | | { |
| | | for (j = 0; j < i0; j++) { |
| | | ca2[j] = '0'; |
| | | } |
| | | |
| | | for (i = i0, j = i0 + 1; j < p + 1; i++, j++) |
| | | { |
| | | for (i = i0, j = i0 + 1; j < p + 1; i++, j++) { |
| | | ca2[j] = ca1[i]; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if ((Math.abs(expon) < 100) && !optionalL) |
| | | { |
| | | if ((Math.abs(expon) < 100) && !optionalL) { |
| | | eSize = 4; |
| | | } else |
| | | { |
| | | } else { |
| | | eSize = 5; |
| | | } |
| | | |
| | | if (alternateForm || !precisionSet || (precision != 0)) |
| | | { |
| | | if (alternateForm || !precisionSet || (precision != 0)) { |
| | | ca2 = new char[2 + p + eSize]; |
| | | } else |
| | | { |
| | | } else { |
| | | ca2 = new char[1 + eSize]; |
| | | } |
| | | |
| | | if (ca1[0] != '0') |
| | | { |
| | | if (ca1[0] != '0') { |
| | | ca2[0] = ca1[0]; |
| | | j = 1; |
| | | } else |
| | | { |
| | | } else { |
| | | for (j = 1; j < ((ePos == -1) |
| | | ? ca1.length |
| | | : ePos); j++) |
| | | { |
| | | if (ca1[j] != '0') |
| | | { |
| | | : ePos); j++) { |
| | | if (ca1[j] != '0') { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (((ePos != -1) && (j < ePos)) || ((ePos == -1) && (j < ca1.length))) |
| | | { |
| | | if (((ePos != -1) && (j < ePos)) || ((ePos == -1) && (j < ca1.length))) { |
| | | ca2[0] = ca1[j]; |
| | | expon -= j; |
| | | j++; |
| | | } else |
| | | { |
| | | } else { |
| | | ca2[0] = '0'; |
| | | j = 2; |
| | | } |
| | | } |
| | | |
| | | if (alternateForm || !precisionSet || (precision != 0)) |
| | | { |
| | | if (alternateForm || !precisionSet || (precision != 0)) { |
| | | ca2[1] = '.'; |
| | | i = 2; |
| | | } else |
| | | { |
| | | } else { |
| | | i = 1; |
| | | } |
| | | |
| | | for (k = 0; (k < p) && (j < ca1.length); j++, i++, k++) |
| | | { |
| | | for (k = 0; (k < p) && (j < ca1.length); j++, i++, k++) { |
| | | ca2[i] = ca1[j]; |
| | | } |
| | | |
| | | for (; i < ca2.length - eSize; i++) |
| | | { |
| | | for (; i < ca2.length - eSize; i++) { |
| | | ca2[i] = '0'; |
| | | } |
| | | |
| | | ca2[i++] = eChar; |
| | | |
| | | if (expon < 0) |
| | | { |
| | | if (expon < 0) { |
| | | ca2[i++] = '-'; |
| | | } else |
| | | { |
| | | } else { |
| | | ca2[i++] = '+'; |
| | | } |
| | | |
| | | expon = Math.abs(expon); |
| | | |
| | | if (expon >= 100) |
| | | { |
| | | switch (expon / 100) |
| | | { |
| | | if (expon >= 100) { |
| | | switch (expon / 100) { |
| | | case 1: |
| | | ca2[i] = '1'; |
| | | |
| | |
| | | i++; |
| | | } |
| | | |
| | | switch ((expon % 100) / 10) |
| | | { |
| | | switch ((expon % 100) / 10) { |
| | | case 0: |
| | | ca2[i] = '0'; |
| | | |
| | |
| | | |
| | | i++; |
| | | |
| | | switch (expon % 10) |
| | | { |
| | | switch (expon % 10) { |
| | | case 0: |
| | | ca2[i] = '0'; |
| | | |
| | |
| | | |
| | | int nZeros = 0; |
| | | |
| | | if (!leftJustify && leadingZeros) |
| | | { |
| | | if (!leftJustify && leadingZeros) { |
| | | int xThousands = 0; |
| | | |
| | | if (thousands) |
| | | { |
| | | if (thousands) { |
| | | int xlead = 0; |
| | | |
| | | if ((ca2[0] == '+') || (ca2[0] == '-') || (ca2[0] == ' ')) |
| | | { |
| | | if ((ca2[0] == '+') || (ca2[0] == '-') || (ca2[0] == ' ')) { |
| | | xlead = 1; |
| | | } |
| | | |
| | | int xdp = xlead; |
| | | |
| | | for (; xdp < ca2.length; xdp++) |
| | | { |
| | | if (ca2[xdp] == '.') |
| | | { |
| | | for (; xdp < ca2.length; xdp++) { |
| | | if (ca2[xdp] == '.') { |
| | | break; |
| | | } |
| | | } |
| | |
| | | xThousands = (xdp - xlead) / 3; |
| | | } |
| | | |
| | | if (fieldWidthSet) |
| | | { |
| | | if (fieldWidthSet) { |
| | | nZeros = fieldWidth - ca2.length; |
| | | } |
| | | |
| | | if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) |
| | | { |
| | | if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) { |
| | | nZeros--; |
| | | } |
| | | |
| | | nZeros -= xThousands; |
| | | |
| | | if (nZeros < 0) |
| | | { |
| | | if (nZeros < 0) { |
| | | nZeros = 0; |
| | | } |
| | | } |
| | | |
| | | j = 0; |
| | | |
| | | if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) |
| | | { |
| | | if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) { |
| | | ca3 = new char[ca2.length + nZeros + 1]; |
| | | j++; |
| | | } else |
| | | { |
| | | } else { |
| | | ca3 = new char[ca2.length + nZeros]; |
| | | } |
| | | |
| | | if (!minusSign) |
| | | { |
| | | if (leadingSign) |
| | | { |
| | | if (!minusSign) { |
| | | if (leadingSign) { |
| | | ca3[0] = '+'; |
| | | } |
| | | |
| | | if (leadingSpace) |
| | | { |
| | | if (leadingSpace) { |
| | | ca3[0] = ' '; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | ca3[0] = '-'; |
| | | } |
| | | |
| | | for (k = 0; k < nZeros; j++, k++) |
| | | { |
| | | for (k = 0; k < nZeros; j++, k++) { |
| | | ca3[j] = '0'; |
| | | } |
| | | |
| | | for (i = 0; (i < ca2.length) && (j < ca3.length); i++, j++) |
| | | { |
| | | for (i = 0; (i < ca2.length) && (j < ca3.length); i++, j++) { |
| | | ca3[j] = ca2[i]; |
| | | } |
| | | |
| | | int lead = 0; |
| | | |
| | | if ((ca3[0] == '+') || (ca3[0] == '-') || (ca3[0] == ' ')) |
| | | { |
| | | if ((ca3[0] == '+') || (ca3[0] == '-') || (ca3[0] == ' ')) { |
| | | lead = 1; |
| | | } |
| | | |
| | | int dp = lead; |
| | | |
| | | for (; dp < ca3.length; dp++) |
| | | { |
| | | if (ca3[dp] == '.') |
| | | { |
| | | for (; dp < ca3.length; dp++) { |
| | | if (ca3[dp] == '.') { |
| | | break; |
| | | } |
| | | } |
| | |
| | | int nThousands = dp / 3; |
| | | |
| | | // Localize the decimal point. |
| | | if (dp < ca3.length) |
| | | { |
| | | if (dp < ca3.length) { |
| | | ca3[dp] = dfs.getDecimalSeparator(); |
| | | } |
| | | |
| | | char[] ca4 = ca3; |
| | | |
| | | if (thousands && (nThousands > 0)) |
| | | { |
| | | if (thousands && (nThousands > 0)) { |
| | | ca4 = new char[ca3.length + nThousands + lead]; |
| | | ca4[0] = ca3[0]; |
| | | |
| | | for (i = lead, k = lead; i < dp; i++) |
| | | { |
| | | if ((i > 0) && (dp - i) % 3 == 0) |
| | | { |
| | | for (i = lead, k = lead; i < dp; i++) { |
| | | if ((i > 0) && (dp - i) % 3 == 0) { |
| | | // ca4[k]=','; |
| | | ca4[k] = dfs.getGroupingSeparator(); |
| | | ca4[k + 1] = ca3[i]; |
| | | k += 2; |
| | | } else |
| | | { |
| | | } else { |
| | | ca4[k] = ca3[i]; |
| | | k++; |
| | | } |
| | | } |
| | | |
| | | for (; i < ca3.length; i++, k++) |
| | | { |
| | | for (; i < ca3.length; i++, k++) { |
| | | ca4[k] = ca3[i]; |
| | | } |
| | | } |
| | |
| | | * @return <code>true</code> if the truncation forces |
| | | * a round that will change the print |
| | | */ |
| | | private boolean checkForCarry(char[] ca1, int icarry) |
| | | { |
| | | private boolean checkForCarry(char[] ca1, int icarry) { |
| | | boolean carry = false; |
| | | |
| | | if (icarry < ca1.length) |
| | | { |
| | | if ((ca1[icarry] == '6') || (ca1[icarry] == '7') || (ca1[icarry] == '8') || (ca1[icarry] == '9')) |
| | | { |
| | | if (icarry < ca1.length) { |
| | | if ((ca1[icarry] == '6') || (ca1[icarry] == '7') || (ca1[icarry] == '8') || (ca1[icarry] == '9')) { |
| | | carry = true; |
| | | } else if (ca1[icarry] == '5') |
| | | { |
| | | } else if (ca1[icarry] == '5') { |
| | | int ii = icarry + 1; |
| | | |
| | | for (; ii < ca1.length; ii++) |
| | | { |
| | | if (ca1[ii] != '0') |
| | | { |
| | | for (; ii < ca1.length; ii++) { |
| | | if (ca1[ii] != '0') { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | carry = ii < ca1.length; |
| | | |
| | | if (!carry && (icarry > 0)) |
| | | { |
| | | if (!carry && (icarry > 0)) { |
| | | carry = ((ca1[icarry - 1] == '1') || (ca1[icarry - 1] == '3') || (ca1[icarry - 1] == '5') |
| | | || (ca1[icarry - 1] == '7') || (ca1[icarry - 1] == '9')); |
| | | } |
| | |
| | | * a round that will change the print still |
| | | * more |
| | | */ |
| | | private boolean startSymbolicCarry(char[] ca, int cLast, int cFirst) |
| | | { |
| | | private boolean startSymbolicCarry(char[] ca, int cLast, int cFirst) { |
| | | boolean carry = true; |
| | | |
| | | for (int i = cLast; carry && (i >= cFirst); i--) |
| | | { |
| | | for (int i = cLast; carry && (i >= cFirst); i--) { |
| | | carry = false; |
| | | |
| | | switch (ca[i]) |
| | | { |
| | | switch (ca[i]) { |
| | | case '0': |
| | | ca[i] = '1'; |
| | | |
| | |
| | | * converted double value. |
| | | * @return the converted double value. |
| | | */ |
| | | private String eFormatString(double x, char eChar) |
| | | { |
| | | private String eFormatString(double x, char eChar) { |
| | | boolean noDigits = false; |
| | | char[] ca4, ca5; |
| | | |
| | | if (Double.isInfinite(x)) |
| | | { |
| | | if (x == Double.POSITIVE_INFINITY) |
| | | { |
| | | if (leadingSign) |
| | | { |
| | | if (Double.isInfinite(x)) { |
| | | if (x == Double.POSITIVE_INFINITY) { |
| | | if (leadingSign) { |
| | | ca4 = "+Inf".toCharArray(); |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | ca4 = " Inf".toCharArray(); |
| | | } else |
| | | { |
| | | } else { |
| | | ca4 = "Inf".toCharArray(); |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | ca4 = "-Inf".toCharArray(); |
| | | } |
| | | |
| | | noDigits = true; |
| | | } else if (Double.isNaN(x)) |
| | | { |
| | | if (leadingSign) |
| | | { |
| | | } else if (Double.isNaN(x)) { |
| | | if (leadingSign) { |
| | | ca4 = "+NaN".toCharArray(); |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | ca4 = " NaN".toCharArray(); |
| | | } else |
| | | { |
| | | } else { |
| | | ca4 = "NaN".toCharArray(); |
| | | } |
| | | |
| | | noDigits = true; |
| | | } else |
| | | { |
| | | } else { |
| | | ca4 = eFormatDigits(x, eChar); |
| | | } |
| | | |
| | |
| | | * @param noDigits NaN or signed Inf |
| | | * @return a padded array of characters |
| | | */ |
| | | private char[] applyFloatPadding(char[] ca4, boolean noDigits) |
| | | { |
| | | private char[] applyFloatPadding(char[] ca4, boolean noDigits) { |
| | | char[] ca5 = ca4; |
| | | |
| | | if (fieldWidthSet) |
| | | { |
| | | if (fieldWidthSet) { |
| | | int i, j, nBlanks; |
| | | |
| | | if (leftJustify) |
| | | { |
| | | if (leftJustify) { |
| | | nBlanks = fieldWidth - ca4.length; |
| | | |
| | | if (nBlanks > 0) |
| | | { |
| | | if (nBlanks > 0) { |
| | | ca5 = new char[ca4.length + nBlanks]; |
| | | |
| | | for (i = 0; i < ca4.length; i++) |
| | | { |
| | | for (i = 0; i < ca4.length; i++) { |
| | | ca5[i] = ca4[i]; |
| | | } |
| | | |
| | | for (j = 0; j < nBlanks; j++, i++) |
| | | { |
| | | for (j = 0; j < nBlanks; j++, i++) { |
| | | ca5[i] = ' '; |
| | | } |
| | | } |
| | | } else if (!leadingZeros || noDigits) |
| | | { |
| | | } else if (!leadingZeros || noDigits) { |
| | | nBlanks = fieldWidth - ca4.length; |
| | | |
| | | if (nBlanks > 0) |
| | | { |
| | | if (nBlanks > 0) { |
| | | ca5 = new char[ca4.length + nBlanks]; |
| | | |
| | | for (i = 0; i < nBlanks; i++) |
| | | { |
| | | for (i = 0; i < nBlanks; i++) { |
| | | ca5[i] = ' '; |
| | | } |
| | | |
| | | for (j = 0; j < ca4.length; i++, j++) |
| | | { |
| | | for (j = 0; j < ca4.length; i++, j++) { |
| | | ca5[i] = ca4[j]; |
| | | } |
| | | } |
| | | } else if (leadingZeros) |
| | | { |
| | | } else if (leadingZeros) { |
| | | nBlanks = fieldWidth - ca4.length; |
| | | |
| | | if (nBlanks > 0) |
| | | { |
| | | if (nBlanks > 0) { |
| | | ca5 = new char[ca4.length + nBlanks]; |
| | | i = 0; |
| | | j = 0; |
| | | |
| | | if (ca4[0] == '-') |
| | | { |
| | | if (ca4[0] == '-') { |
| | | ca5[0] = '-'; |
| | | i++; |
| | | j++; |
| | | } |
| | | |
| | | for (int k = 0; k < nBlanks; i++, k++) |
| | | { |
| | | for (int k = 0; k < nBlanks; i++, k++) { |
| | | ca5[i] = '0'; |
| | | } |
| | | |
| | | for (; j < ca4.length; i++, j++) |
| | | { |
| | | for (; j < ca4.length; i++, j++) { |
| | | ca5[i] = ca4[j]; |
| | | } |
| | | } |
| | |
| | | * @param x the double to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printFFormat(double x) |
| | | { |
| | | private String printFFormat(double x) { |
| | | return fFormatString(x); |
| | | } |
| | | |
| | |
| | | * @param x the double to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printEFormat(double x) |
| | | { |
| | | if (conversionCharacter == 'e') |
| | | { |
| | | private String printEFormat(double x) { |
| | | if (conversionCharacter == 'e') { |
| | | return eFormatString(x, 'e'); |
| | | } else |
| | | { |
| | | } else { |
| | | return eFormatString(x, 'E'); |
| | | } |
| | | } |
| | |
| | | * @param x the double to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printGFormat(double x) |
| | | { |
| | | private String printGFormat(double x) { |
| | | String sx, sy, sz, ret; |
| | | int savePrecision = precision; |
| | | int i; |
| | | char[] ca4, ca5; |
| | | boolean noDigits = false; |
| | | |
| | | if (Double.isInfinite(x)) |
| | | { |
| | | if (x == Double.POSITIVE_INFINITY) |
| | | { |
| | | if (leadingSign) |
| | | { |
| | | if (Double.isInfinite(x)) { |
| | | if (x == Double.POSITIVE_INFINITY) { |
| | | if (leadingSign) { |
| | | ca4 = "+Inf".toCharArray(); |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | ca4 = " Inf".toCharArray(); |
| | | } else |
| | | { |
| | | } else { |
| | | ca4 = "Inf".toCharArray(); |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | ca4 = "-Inf".toCharArray(); |
| | | } |
| | | |
| | | noDigits = true; |
| | | } else if (Double.isNaN(x)) |
| | | { |
| | | if (leadingSign) |
| | | { |
| | | } else if (Double.isNaN(x)) { |
| | | if (leadingSign) { |
| | | ca4 = "+NaN".toCharArray(); |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | ca4 = " NaN".toCharArray(); |
| | | } else |
| | | { |
| | | } else { |
| | | ca4 = "NaN".toCharArray(); |
| | | } |
| | | |
| | | noDigits = true; |
| | | } else |
| | | { |
| | | if (!precisionSet) |
| | | { |
| | | } else { |
| | | if (!precisionSet) { |
| | | precision = defaultDigits; |
| | | } |
| | | |
| | | if (precision == 0) |
| | | { |
| | | if (precision == 0) { |
| | | precision = 1; |
| | | } |
| | | |
| | | int ePos = -1; |
| | | |
| | | if (conversionCharacter == 'g') |
| | | { |
| | | if (conversionCharacter == 'g') { |
| | | sx = eFormatString(x, 'e').trim(); |
| | | ePos = sx.indexOf('e'); |
| | | } else |
| | | { |
| | | } else { |
| | | sx = eFormatString(x, 'E').trim(); |
| | | ePos = sx.indexOf('E'); |
| | | } |
| | |
| | | |
| | | int expon = 0; |
| | | |
| | | if (sx.charAt(i) == '-') |
| | | { |
| | | for (++i; i < sx.length(); i++) |
| | | { |
| | | if (sx.charAt(i) != '0') |
| | | { |
| | | if (sx.charAt(i) == '-') { |
| | | for (++i; i < sx.length(); i++) { |
| | | if (sx.charAt(i) != '0') { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (i < sx.length()) |
| | | { |
| | | if (i < sx.length()) { |
| | | expon = -Integer.parseInt(sx.substring(i)); |
| | | } |
| | | } else |
| | | { |
| | | if (sx.charAt(i) == '+') |
| | | { |
| | | } else { |
| | | if (sx.charAt(i) == '+') { |
| | | ++i; |
| | | } |
| | | |
| | | for (; i < sx.length(); i++) |
| | | { |
| | | if (sx.charAt(i) != '0') |
| | | { |
| | | for (; i < sx.length(); i++) { |
| | | if (sx.charAt(i) != '0') { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (i < sx.length()) |
| | | { |
| | | if (i < sx.length()) { |
| | | expon = Integer.parseInt(sx.substring(i)); |
| | | } |
| | | } |
| | |
| | | // Trim trailing zeros. |
| | | // If the radix character is not followed by |
| | | // a digit, trim it, too. |
| | | if (!alternateForm) |
| | | { |
| | | if ((expon >= -4) && (expon < precision)) |
| | | { |
| | | if (!alternateForm) { |
| | | if ((expon >= -4) && (expon < precision)) { |
| | | sy = fFormatString(x).trim(); |
| | | } else |
| | | { |
| | | } else { |
| | | sy = sx.substring(0, ePos); |
| | | } |
| | | |
| | | i = sy.length() - 1; |
| | | |
| | | for (; i >= 0; i--) |
| | | { |
| | | if (sy.charAt(i) != '0') |
| | | { |
| | | for (; i >= 0; i--) { |
| | | if (sy.charAt(i) != '0') { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if ((i >= 0) && (sy.charAt(i) == '.')) |
| | | { |
| | | if ((i >= 0) && (sy.charAt(i) == '.')) { |
| | | i--; |
| | | } |
| | | |
| | | if (i == -1) |
| | | { |
| | | if (i == -1) { |
| | | sz = "0"; |
| | | } else if (!Character.isDigit(sy.charAt(i))) |
| | | { |
| | | } else if (!Character.isDigit(sy.charAt(i))) { |
| | | sz = sy.substring(0, i + 1) + "0"; |
| | | } else |
| | | { |
| | | } else { |
| | | sz = sy.substring(0, i + 1); |
| | | } |
| | | |
| | | if ((expon >= -4) && (expon < precision)) |
| | | { |
| | | if ((expon >= -4) && (expon < precision)) { |
| | | ret = sz; |
| | | } else |
| | | { |
| | | } else { |
| | | ret = sz + sx.substring(ePos); |
| | | } |
| | | } else |
| | | { |
| | | if ((expon >= -4) && (expon < precision)) |
| | | { |
| | | } else { |
| | | if ((expon >= -4) && (expon < precision)) { |
| | | ret = fFormatString(x).trim(); |
| | | } else |
| | | { |
| | | } else { |
| | | ret = sx; |
| | | } |
| | | } |
| | | |
| | | // leading space was trimmed off during |
| | | // construction |
| | | if (leadingSpace) |
| | | { |
| | | if (x >= 0) |
| | | { |
| | | if (leadingSpace) { |
| | | if (x >= 0) { |
| | | ret = " " + ret; |
| | | } |
| | | } |
| | |
| | | * @param x the short to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printDFormat(short x) |
| | | { |
| | | private String printDFormat(short x) { |
| | | return printDFormat(Short.toString(x)); |
| | | } |
| | | |
| | |
| | | * @param x the long to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printDFormat(long x) |
| | | { |
| | | private String printDFormat(long x) { |
| | | return printDFormat(Long.toString(x)); |
| | | } |
| | | |
| | |
| | | * @param x the int to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printDFormat(int x) |
| | | { |
| | | private String printDFormat(int x) { |
| | | return printDFormat(Integer.toString(x)); |
| | | } |
| | | |
| | |
| | | * String. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printDFormat(String sx) |
| | | { |
| | | private String printDFormat(String sx) { |
| | | int nLeadingZeros = 0; |
| | | int nBlanks = 0, |
| | | n = 0; |
| | |
| | | jFirst = 0; |
| | | boolean neg = sx.charAt(0) == '-'; |
| | | |
| | | if (sx.equals("0") && precisionSet && (precision == 0)) |
| | | { |
| | | if (sx.equals("0") && precisionSet && (precision == 0)) { |
| | | sx = ""; |
| | | } |
| | | |
| | | if (!neg) |
| | | { |
| | | if (precisionSet && (sx.length() < precision)) |
| | | { |
| | | if (!neg) { |
| | | if (precisionSet && (sx.length() < precision)) { |
| | | nLeadingZeros = precision - sx.length(); |
| | | } |
| | | } else |
| | | { |
| | | if (precisionSet && (sx.length() - 1) < precision) |
| | | { |
| | | } else { |
| | | if (precisionSet && (sx.length() - 1) < precision) { |
| | | nLeadingZeros = precision - sx.length() + 1; |
| | | } |
| | | } |
| | | |
| | | if (nLeadingZeros < 0) |
| | | { |
| | | if (nLeadingZeros < 0) { |
| | | nLeadingZeros = 0; |
| | | } |
| | | |
| | | if (fieldWidthSet) |
| | | { |
| | | if (fieldWidthSet) { |
| | | nBlanks = fieldWidth - nLeadingZeros - sx.length(); |
| | | |
| | | if (!neg && (leadingSign || leadingSpace)) |
| | | { |
| | | if (!neg && (leadingSign || leadingSpace)) { |
| | | nBlanks--; |
| | | } |
| | | } |
| | | |
| | | if (nBlanks < 0) |
| | | { |
| | | if (nBlanks < 0) { |
| | | nBlanks = 0; |
| | | } |
| | | |
| | | if (leadingSign) |
| | | { |
| | | if (leadingSign) { |
| | | n++; |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | n++; |
| | | } |
| | | |
| | |
| | | |
| | | char[] ca = new char[n]; |
| | | |
| | | if (leftJustify) |
| | | { |
| | | if (neg) |
| | | { |
| | | if (leftJustify) { |
| | | if (neg) { |
| | | ca[i++] = '-'; |
| | | } else if (leadingSign) |
| | | { |
| | | } else if (leadingSign) { |
| | | ca[i++] = '+'; |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | ca[i++] = ' '; |
| | | } |
| | | |
| | |
| | | ? 1 |
| | | : 0; |
| | | |
| | | for (int j = 0; j < nLeadingZeros; i++, j++) |
| | | { |
| | | for (int j = 0; j < nLeadingZeros; i++, j++) { |
| | | ca[i] = '0'; |
| | | } |
| | | |
| | | for (int j = jFirst; j < csx.length; j++, i++) |
| | | { |
| | | for (int j = jFirst; j < csx.length; j++, i++) { |
| | | ca[i] = csx[j]; |
| | | } |
| | | |
| | | for (int j = 0; j < nBlanks; i++, j++) |
| | | { |
| | | for (int j = 0; j < nBlanks; i++, j++) { |
| | | ca[i] = ' '; |
| | | } |
| | | } else |
| | | { |
| | | if (!leadingZeros) |
| | | { |
| | | for (i = 0; i < nBlanks; i++) |
| | | { |
| | | } else { |
| | | if (!leadingZeros) { |
| | | for (i = 0; i < nBlanks; i++) { |
| | | ca[i] = ' '; |
| | | } |
| | | |
| | | if (neg) |
| | | { |
| | | if (neg) { |
| | | ca[i++] = '-'; |
| | | } else if (leadingSign) |
| | | { |
| | | } else if (leadingSign) { |
| | | ca[i++] = '+'; |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | ca[i++] = ' '; |
| | | } |
| | | } else |
| | | { |
| | | if (neg) |
| | | { |
| | | } else { |
| | | if (neg) { |
| | | ca[i++] = '-'; |
| | | } else if (leadingSign) |
| | | { |
| | | } else if (leadingSign) { |
| | | ca[i++] = '+'; |
| | | } else if (leadingSpace) |
| | | { |
| | | } else if (leadingSpace) { |
| | | ca[i++] = ' '; |
| | | } |
| | | |
| | | for (int j = 0; j < nBlanks; j++, i++) |
| | | { |
| | | for (int j = 0; j < nBlanks; j++, i++) { |
| | | ca[i] = '0'; |
| | | } |
| | | } |
| | | |
| | | for (int j = 0; j < nLeadingZeros; j++, i++) |
| | | { |
| | | for (int j = 0; j < nLeadingZeros; j++, i++) { |
| | | ca[i] = '0'; |
| | | } |
| | | |
| | |
| | | ? 1 |
| | | : 0; |
| | | |
| | | for (int j = jFirst; j < csx.length; j++, i++) |
| | | { |
| | | for (int j = jFirst; j < csx.length; j++, i++) { |
| | | ca[i] = csx[j]; |
| | | } |
| | | } |
| | |
| | | * @param x the short to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printXFormat(short x) |
| | | { |
| | | private String printXFormat(short x) { |
| | | String sx = null; |
| | | |
| | | if (x == Short.MIN_VALUE) |
| | | { |
| | | if (x == Short.MIN_VALUE) { |
| | | sx = "8000"; |
| | | } else if (x < 0) |
| | | { |
| | | } else if (x < 0) { |
| | | String t; |
| | | |
| | | if (x == Short.MIN_VALUE) |
| | | { |
| | | if (x == Short.MIN_VALUE) { |
| | | t = "0"; |
| | | } else |
| | | { |
| | | } else { |
| | | t = Integer.toString((~(-x - 1)) ^ Short.MIN_VALUE, 16); |
| | | |
| | | if ((t.charAt(0) == 'F') || (t.charAt(0) == 'f')) |
| | | { |
| | | if ((t.charAt(0) == 'F') || (t.charAt(0) == 'f')) { |
| | | t = t.substring(16, 32); |
| | | } |
| | | } |
| | | |
| | | switch (t.length()) |
| | | { |
| | | switch (t.length()) { |
| | | case 1: |
| | | sx = "800" + t; |
| | | |
| | |
| | | break; |
| | | |
| | | case 4: |
| | | switch (t.charAt(0)) |
| | | { |
| | | switch (t.charAt(0)) { |
| | | case '1': |
| | | sx = "9" + t.substring(1, 4); |
| | | |
| | |
| | | |
| | | break; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | sx = Integer.toString((int) x, 16); |
| | | } |
| | | |
| | |
| | | * @param x the long to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printXFormat(long x) |
| | | { |
| | | private String printXFormat(long x) { |
| | | String sx = null; |
| | | |
| | | if (x == Long.MIN_VALUE) |
| | | { |
| | | if (x == Long.MIN_VALUE) { |
| | | sx = "8000000000000000"; |
| | | } else if (x < 0) |
| | | { |
| | | } else if (x < 0) { |
| | | String t = Long.toString((~(-x - 1)) ^ Long.MIN_VALUE, 16); |
| | | |
| | | switch (t.length()) |
| | | { |
| | | switch (t.length()) { |
| | | case 1: |
| | | sx = "800000000000000" + t; |
| | | |
| | |
| | | break; |
| | | |
| | | case 16: |
| | | switch (t.charAt(0)) |
| | | { |
| | | switch (t.charAt(0)) { |
| | | case '1': |
| | | sx = "9" + t.substring(1, 16); |
| | | |
| | |
| | | |
| | | break; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | sx = Long.toString(x, 16); |
| | | } |
| | | |
| | |
| | | * @param x the int to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printXFormat(int x) |
| | | { |
| | | private String printXFormat(int x) { |
| | | String sx = null; |
| | | |
| | | if (x == Integer.MIN_VALUE) |
| | | { |
| | | if (x == Integer.MIN_VALUE) { |
| | | sx = "80000000"; |
| | | } else if (x < 0) |
| | | { |
| | | } else if (x < 0) { |
| | | String t = Integer.toString((~(-x - 1)) ^ Integer.MIN_VALUE, 16); |
| | | |
| | | switch (t.length()) |
| | | { |
| | | switch (t.length()) { |
| | | case 1: |
| | | sx = "8000000" + t; |
| | | |
| | |
| | | break; |
| | | |
| | | case 8: |
| | | switch (t.charAt(0)) |
| | | { |
| | | switch (t.charAt(0)) { |
| | | case '1': |
| | | sx = "9" + t.substring(1, 8); |
| | | |
| | |
| | | |
| | | break; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | sx = Integer.toString(x, 16); |
| | | } |
| | | |
| | |
| | | * String. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printXFormat(String sx) |
| | | { |
| | | private String printXFormat(String sx) { |
| | | int nLeadingZeros = 0; |
| | | int nBlanks = 0; |
| | | |
| | | if (sx.equals("0") && precisionSet && (precision == 0)) |
| | | { |
| | | if (sx.equals("0") && precisionSet && (precision == 0)) { |
| | | sx = ""; |
| | | } |
| | | |
| | | if (precisionSet) |
| | | { |
| | | if (precisionSet) { |
| | | nLeadingZeros = precision - sx.length(); |
| | | } |
| | | |
| | | if (nLeadingZeros < 0) |
| | | { |
| | | if (nLeadingZeros < 0) { |
| | | nLeadingZeros = 0; |
| | | } |
| | | |
| | | if (fieldWidthSet) |
| | | { |
| | | if (fieldWidthSet) { |
| | | nBlanks = fieldWidth - nLeadingZeros - sx.length(); |
| | | |
| | | if (alternateForm) |
| | | { |
| | | if (alternateForm) { |
| | | nBlanks = nBlanks - 2; |
| | | } |
| | | } |
| | | |
| | | if (nBlanks < 0) |
| | | { |
| | | if (nBlanks < 0) { |
| | | nBlanks = 0; |
| | | } |
| | | |
| | | int n = 0; |
| | | |
| | | if (alternateForm) |
| | | { |
| | | if (alternateForm) { |
| | | n += 2; |
| | | } |
| | | |
| | |
| | | char[] ca = new char[n]; |
| | | int i = 0; |
| | | |
| | | if (leftJustify) |
| | | { |
| | | if (alternateForm) |
| | | { |
| | | if (leftJustify) { |
| | | if (alternateForm) { |
| | | ca[i++] = '0'; |
| | | ca[i++] = 'x'; |
| | | } |
| | | |
| | | for (int j = 0; j < nLeadingZeros; j++, i++) |
| | | { |
| | | for (int j = 0; j < nLeadingZeros; j++, i++) { |
| | | ca[i] = '0'; |
| | | } |
| | | |
| | | char[] csx = sx.toCharArray(); |
| | | |
| | | for (int j = 0; j < csx.length; j++, i++) |
| | | { |
| | | for (int j = 0; j < csx.length; j++, i++) { |
| | | ca[i] = csx[j]; |
| | | } |
| | | |
| | | for (int j = 0; j < nBlanks; j++, i++) |
| | | { |
| | | for (int j = 0; j < nBlanks; j++, i++) { |
| | | ca[i] = ' '; |
| | | } |
| | | } else |
| | | { |
| | | if (!leadingZeros) |
| | | { |
| | | for (int j = 0; j < nBlanks; j++, i++) |
| | | { |
| | | } else { |
| | | if (!leadingZeros) { |
| | | for (int j = 0; j < nBlanks; j++, i++) { |
| | | ca[i] = ' '; |
| | | } |
| | | } |
| | | |
| | | if (alternateForm) |
| | | { |
| | | if (alternateForm) { |
| | | ca[i++] = '0'; |
| | | ca[i++] = 'x'; |
| | | } |
| | | |
| | | if (leadingZeros) |
| | | { |
| | | for (int j = 0; j < nBlanks; j++, i++) |
| | | { |
| | | if (leadingZeros) { |
| | | for (int j = 0; j < nBlanks; j++, i++) { |
| | | ca[i] = '0'; |
| | | } |
| | | } |
| | | |
| | | for (int j = 0; j < nLeadingZeros; j++, i++) |
| | | { |
| | | for (int j = 0; j < nLeadingZeros; j++, i++) { |
| | | ca[i] = '0'; |
| | | } |
| | | |
| | | char[] csx = sx.toCharArray(); |
| | | |
| | | for (int j = 0; j < csx.length; j++, i++) |
| | | { |
| | | for (int j = 0; j < csx.length; j++, i++) { |
| | | ca[i] = csx[j]; |
| | | } |
| | | } |
| | | |
| | | String caReturn = new String(ca); |
| | | |
| | | if (conversionCharacter == 'X') |
| | | { |
| | | if (conversionCharacter == 'X') { |
| | | caReturn = caReturn.toUpperCase(); |
| | | } |
| | | |
| | |
| | | * @param x the short to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printOFormat(short x) |
| | | { |
| | | private String printOFormat(short x) { |
| | | String sx = null; |
| | | |
| | | if (x == Short.MIN_VALUE) |
| | | { |
| | | if (x == Short.MIN_VALUE) { |
| | | sx = "100000"; |
| | | } else if (x < 0) |
| | | { |
| | | } else if (x < 0) { |
| | | String t = Integer.toString((~(-x - 1)) ^ Short.MIN_VALUE, 8); |
| | | |
| | | switch (t.length()) |
| | | { |
| | | switch (t.length()) { |
| | | case 1: |
| | | sx = "10000" + t; |
| | | |
| | |
| | | |
| | | break; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | sx = Integer.toString((int) x, 8); |
| | | } |
| | | |
| | |
| | | * @param x the long to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printOFormat(long x) |
| | | { |
| | | private String printOFormat(long x) { |
| | | String sx = null; |
| | | |
| | | if (x == Long.MIN_VALUE) |
| | | { |
| | | if (x == Long.MIN_VALUE) { |
| | | sx = "1000000000000000000000"; |
| | | } else if (x < 0) |
| | | { |
| | | } else if (x < 0) { |
| | | String t = Long.toString((~(-x - 1)) ^ Long.MIN_VALUE, 8); |
| | | |
| | | switch (t.length()) |
| | | { |
| | | switch (t.length()) { |
| | | case 1: |
| | | sx = "100000000000000000000" + t; |
| | | |
| | |
| | | |
| | | break; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | sx = Long.toString(x, 8); |
| | | } |
| | | |
| | |
| | | * @param x the int to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printOFormat(int x) |
| | | { |
| | | private String printOFormat(int x) { |
| | | String sx = null; |
| | | |
| | | if (x == Integer.MIN_VALUE) |
| | | { |
| | | if (x == Integer.MIN_VALUE) { |
| | | sx = "20000000000"; |
| | | } else if (x < 0) |
| | | { |
| | | } else if (x < 0) { |
| | | String t = Integer.toString((~(-x - 1)) ^ Integer.MIN_VALUE, 8); |
| | | |
| | | switch (t.length()) |
| | | { |
| | | switch (t.length()) { |
| | | case 1: |
| | | sx = "2000000000" + t; |
| | | |
| | |
| | | |
| | | break; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | sx = Integer.toString(x, 8); |
| | | } |
| | | |
| | |
| | | * String. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printOFormat(String sx) |
| | | { |
| | | private String printOFormat(String sx) { |
| | | int nLeadingZeros = 0; |
| | | int nBlanks = 0; |
| | | |
| | | if (sx.equals("0") && precisionSet && (precision == 0)) |
| | | { |
| | | if (sx.equals("0") && precisionSet && (precision == 0)) { |
| | | sx = ""; |
| | | } |
| | | |
| | | if (precisionSet) |
| | | { |
| | | if (precisionSet) { |
| | | nLeadingZeros = precision - sx.length(); |
| | | } |
| | | |
| | | if (alternateForm) |
| | | { |
| | | if (alternateForm) { |
| | | nLeadingZeros++; |
| | | } |
| | | |
| | | if (nLeadingZeros < 0) |
| | | { |
| | | if (nLeadingZeros < 0) { |
| | | nLeadingZeros = 0; |
| | | } |
| | | |
| | | if (fieldWidthSet) |
| | | { |
| | | if (fieldWidthSet) { |
| | | nBlanks = fieldWidth - nLeadingZeros - sx.length(); |
| | | } |
| | | |
| | | if (nBlanks < 0) |
| | | { |
| | | if (nBlanks < 0) { |
| | | nBlanks = 0; |
| | | } |
| | | |
| | |
| | | char[] ca = new char[n]; |
| | | int i; |
| | | |
| | | if (leftJustify) |
| | | { |
| | | for (i = 0; i < nLeadingZeros; i++) |
| | | { |
| | | if (leftJustify) { |
| | | for (i = 0; i < nLeadingZeros; i++) { |
| | | ca[i] = '0'; |
| | | } |
| | | |
| | | char[] csx = sx.toCharArray(); |
| | | |
| | | for (int j = 0; j < csx.length; j++, i++) |
| | | { |
| | | for (int j = 0; j < csx.length; j++, i++) { |
| | | ca[i] = csx[j]; |
| | | } |
| | | |
| | | for (int j = 0; j < nBlanks; j++, i++) |
| | | { |
| | | for (int j = 0; j < nBlanks; j++, i++) { |
| | | ca[i] = ' '; |
| | | } |
| | | } else |
| | | { |
| | | if (leadingZeros) |
| | | { |
| | | for (i = 0; i < nBlanks; i++) |
| | | { |
| | | } else { |
| | | if (leadingZeros) { |
| | | for (i = 0; i < nBlanks; i++) { |
| | | ca[i] = '0'; |
| | | } |
| | | } else |
| | | { |
| | | for (i = 0; i < nBlanks; i++) |
| | | { |
| | | } else { |
| | | for (i = 0; i < nBlanks; i++) { |
| | | ca[i] = ' '; |
| | | } |
| | | } |
| | | |
| | | for (int j = 0; j < nLeadingZeros; j++, i++) |
| | | { |
| | | for (int j = 0; j < nLeadingZeros; j++, i++) { |
| | | ca[i] = '0'; |
| | | } |
| | | |
| | | char[] csx = sx.toCharArray(); |
| | | |
| | | for (int j = 0; j < csx.length; j++, i++) |
| | | { |
| | | for (int j = 0; j < csx.length; j++, i++) { |
| | | ca[i] = csx[j]; |
| | | } |
| | | } |
| | |
| | | * @param x the char to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printCFormat(char x) |
| | | { |
| | | private String printCFormat(char x) { |
| | | int nPrint = 1; |
| | | int width = fieldWidth; |
| | | |
| | | if (!fieldWidthSet) |
| | | { |
| | | if (!fieldWidthSet) { |
| | | width = nPrint; |
| | | } |
| | | |
| | | char[] ca = new char[width]; |
| | | int i = 0; |
| | | |
| | | if (leftJustify) |
| | | { |
| | | if (leftJustify) { |
| | | ca[0] = x; |
| | | |
| | | for (i = 1; i <= width - nPrint; i++) |
| | | { |
| | | for (i = 1; i <= width - nPrint; i++) { |
| | | ca[i] = ' '; |
| | | } |
| | | } else |
| | | { |
| | | for (i = 0; i < width - nPrint; i++) |
| | | { |
| | | } else { |
| | | for (i = 0; i < width - nPrint; i++) { |
| | | ca[i] = ' '; |
| | | } |
| | | |
| | |
| | | * @param x the String to format. |
| | | * @return the formatted String. |
| | | */ |
| | | private String printSFormat(String x) |
| | | { |
| | | private String printSFormat(String x) { |
| | | int nPrint = x.length(); |
| | | int width = fieldWidth; |
| | | |
| | | if (precisionSet && (nPrint > precision)) |
| | | { |
| | | if (precisionSet && (nPrint > precision)) { |
| | | nPrint = precision; |
| | | } |
| | | |
| | | if (!fieldWidthSet) |
| | | { |
| | | if (!fieldWidthSet) { |
| | | width = nPrint; |
| | | } |
| | | |
| | | int n = 0; |
| | | |
| | | if (width > nPrint) |
| | | { |
| | | if (width > nPrint) { |
| | | n += width - nPrint; |
| | | } |
| | | |
| | | if (nPrint >= x.length()) |
| | | { |
| | | if (nPrint >= x.length()) { |
| | | n += x.length(); |
| | | } else |
| | | { |
| | | } else { |
| | | n += nPrint; |
| | | } |
| | | |
| | | char[] ca = new char[n]; |
| | | int i = 0; |
| | | |
| | | if (leftJustify) |
| | | { |
| | | if (nPrint >= x.length()) |
| | | { |
| | | if (leftJustify) { |
| | | if (nPrint >= x.length()) { |
| | | char[] csx = x.toCharArray(); |
| | | |
| | | for (i = 0; i < x.length(); i++) |
| | | { |
| | | for (i = 0; i < x.length(); i++) { |
| | | ca[i] = csx[i]; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | char[] csx = x.substring(0, nPrint).toCharArray(); |
| | | |
| | | for (i = 0; i < nPrint; i++) |
| | | { |
| | | for (i = 0; i < nPrint; i++) { |
| | | ca[i] = csx[i]; |
| | | } |
| | | } |
| | | |
| | | for (int j = 0; j < width - nPrint; j++, i++) |
| | | { |
| | | for (int j = 0; j < width - nPrint; j++, i++) { |
| | | ca[i] = ' '; |
| | | } |
| | | } else |
| | | { |
| | | for (i = 0; i < width - nPrint; i++) |
| | | { |
| | | } else { |
| | | for (i = 0; i < width - nPrint; i++) { |
| | | ca[i] = ' '; |
| | | } |
| | | |
| | | if (nPrint >= x.length()) |
| | | { |
| | | if (nPrint >= x.length()) { |
| | | char[] csx = x.toCharArray(); |
| | | |
| | | for (int j = 0; j < x.length(); i++, j++) |
| | | { |
| | | for (int j = 0; j < x.length(); i++, j++) { |
| | | ca[i] = csx[j]; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | char[] csx = x.substring(0, nPrint).toCharArray(); |
| | | |
| | | for (int j = 0; j < nPrint; i++, j++) |
| | | { |
| | | for (int j = 0; j < nPrint; i++, j++) { |
| | | ca[i] = csx[j]; |
| | | } |
| | | } |
| | |
| | | * character is there, and |
| | | * <code>false</code> otherwise. |
| | | */ |
| | | private boolean setConversionCharacter() |
| | | { |
| | | private boolean setConversionCharacter() { |
| | | /* idfgGoxXeEcs */ |
| | | boolean ret = false; |
| | | |
| | | conversionCharacter = '\0'; |
| | | |
| | | if (pos < fmt.length()) |
| | | { |
| | | if (pos < fmt.length()) { |
| | | char c = fmt.charAt(pos); |
| | | |
| | | if ((c == 'i') || (c == 'd') || (c == 'f') || (c == 'g') || (c == 'G') || (c == 'o') || (c == 'x') || (c == 'X') |
| | | || (c == 'e') || (c == 'E') || (c == 'c') || (c == 's') || (c == '%')) |
| | | { |
| | | || (c == 'e') || (c == 'E') || (c == 'c') || (c == 's') || (c == '%')) { |
| | | conversionCharacter = c; |
| | | pos++; |
| | | ret = true; |
| | |
| | | * respectively, before formatting. If any of |
| | | * these is present, store them. |
| | | */ |
| | | private void setOptionalHL() |
| | | { |
| | | private void setOptionalHL() { |
| | | optionalh = false; |
| | | optionall = false; |
| | | optionalL = false; |
| | | |
| | | if (pos < fmt.length()) |
| | | { |
| | | if (pos < fmt.length()) { |
| | | char c = fmt.charAt(pos); |
| | | |
| | | if (c == 'h') |
| | | { |
| | | if (c == 'h') { |
| | | optionalh = true; |
| | | pos++; |
| | | } else if (c == 'l') |
| | | { |
| | | } else if (c == 'l') { |
| | | optionall = true; |
| | | pos++; |
| | | } else if (c == 'L') |
| | | { |
| | | } else if (c == 'L') { |
| | | optionalL = true; |
| | | pos++; |
| | | } |
| | |
| | | /** |
| | | * Set the precision. |
| | | */ |
| | | private void setPrecision() |
| | | { |
| | | private void setPrecision() { |
| | | int firstPos = pos; |
| | | |
| | | precisionSet = false; |
| | | |
| | | if ((pos < fmt.length()) && (fmt.charAt(pos) == '.')) |
| | | { |
| | | if ((pos < fmt.length()) && (fmt.charAt(pos) == '.')) { |
| | | pos++; |
| | | |
| | | if ((pos < fmt.length()) && (fmt.charAt(pos) == '*')) |
| | | { |
| | | if ((pos < fmt.length()) && (fmt.charAt(pos) == '*')) { |
| | | pos++; |
| | | |
| | | if (!setPrecisionArgPosition()) |
| | | { |
| | | if (!setPrecisionArgPosition()) { |
| | | variablePrecision = true; |
| | | precisionSet = true; |
| | | } |
| | | |
| | | return; |
| | | } else |
| | | { |
| | | while (pos < fmt.length()) |
| | | { |
| | | } else { |
| | | while (pos < fmt.length()) { |
| | | char c = fmt.charAt(pos); |
| | | |
| | | if (Character.isDigit(c)) |
| | | { |
| | | if (Character.isDigit(c)) { |
| | | pos++; |
| | | } else |
| | | { |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (pos > firstPos + 1) |
| | | { |
| | | if (pos > firstPos + 1) { |
| | | String sz = fmt.substring(firstPos + 1, pos); |
| | | |
| | | precision = Integer.parseInt(sz); |
| | |
| | | /** |
| | | * Set the field width. |
| | | */ |
| | | private void setFieldWidth() |
| | | { |
| | | private void setFieldWidth() { |
| | | int firstPos = pos; |
| | | |
| | | fieldWidth = 0; |
| | | fieldWidthSet = false; |
| | | |
| | | if ((pos < fmt.length()) && (fmt.charAt(pos) == '*')) |
| | | { |
| | | if ((pos < fmt.length()) && (fmt.charAt(pos) == '*')) { |
| | | pos++; |
| | | |
| | | if (!setFieldWidthArgPosition()) |
| | | { |
| | | if (!setFieldWidthArgPosition()) { |
| | | variableFieldWidth = true; |
| | | fieldWidthSet = true; |
| | | } |
| | | } else |
| | | { |
| | | while (pos < fmt.length()) |
| | | { |
| | | } else { |
| | | while (pos < fmt.length()) { |
| | | char c = fmt.charAt(pos); |
| | | |
| | | if (Character.isDigit(c)) |
| | | { |
| | | if (Character.isDigit(c)) { |
| | | pos++; |
| | | } else |
| | | { |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if ((firstPos < pos) && (firstPos < fmt.length())) |
| | | { |
| | | if ((firstPos < pos) && (firstPos < fmt.length())) { |
| | | String sz = fmt.substring(firstPos, pos); |
| | | |
| | | fieldWidth = Integer.parseInt(sz); |
| | |
| | | /** |
| | | * Store the digits <code>n</code> in %n$ forms. |
| | | */ |
| | | private void setArgPosition() |
| | | { |
| | | private void setArgPosition() { |
| | | int xPos; |
| | | |
| | | for (xPos = pos; xPos < fmt.length(); xPos++) |
| | | { |
| | | if (!Character.isDigit(fmt.charAt(xPos))) |
| | | { |
| | | for (xPos = pos; xPos < fmt.length(); xPos++) { |
| | | if (!Character.isDigit(fmt.charAt(xPos))) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if ((xPos > pos) && (xPos < fmt.length())) |
| | | { |
| | | if (fmt.charAt(xPos) == '$') |
| | | { |
| | | if ((xPos > pos) && (xPos < fmt.length())) { |
| | | if (fmt.charAt(xPos) == '$') { |
| | | positionalSpecification = true; |
| | | argumentPosition = Integer.parseInt(fmt.substring(pos, xPos)); |
| | | pos = xPos + 1; |
| | |
| | | /** |
| | | * Store the digits <code>n</code> in *n$ forms. |
| | | */ |
| | | private boolean setFieldWidthArgPosition() |
| | | { |
| | | private boolean setFieldWidthArgPosition() { |
| | | boolean ret = false; |
| | | int xPos; |
| | | |
| | | for (xPos = pos; xPos < fmt.length(); xPos++) |
| | | { |
| | | if (!Character.isDigit(fmt.charAt(xPos))) |
| | | { |
| | | for (xPos = pos; xPos < fmt.length(); xPos++) { |
| | | if (!Character.isDigit(fmt.charAt(xPos))) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if ((xPos > pos) && (xPos < fmt.length())) |
| | | { |
| | | if (fmt.charAt(xPos) == '$') |
| | | { |
| | | if ((xPos > pos) && (xPos < fmt.length())) { |
| | | if (fmt.charAt(xPos) == '$') { |
| | | positionalFieldWidth = true; |
| | | argumentPositionForFieldWidth = Integer.parseInt(fmt.substring(pos, xPos)); |
| | | pos = xPos + 1; |
| | |
| | | /** |
| | | * Store the digits <code>n</code> in *n$ forms. |
| | | */ |
| | | private boolean setPrecisionArgPosition() |
| | | { |
| | | private boolean setPrecisionArgPosition() { |
| | | boolean ret = false; |
| | | int xPos; |
| | | |
| | | for (xPos = pos; xPos < fmt.length(); xPos++) |
| | | { |
| | | if (!Character.isDigit(fmt.charAt(xPos))) |
| | | { |
| | | for (xPos = pos; xPos < fmt.length(); xPos++) { |
| | | if (!Character.isDigit(fmt.charAt(xPos))) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if ((xPos > pos) && (xPos < fmt.length())) |
| | | { |
| | | if (fmt.charAt(xPos) == '$') |
| | | { |
| | | if ((xPos > pos) && (xPos < fmt.length())) { |
| | | if (fmt.charAt(xPos) == '$') { |
| | | positionalPrecision = true; |
| | | argumentPositionForPrecision = Integer.parseInt(fmt.substring(pos, xPos)); |
| | | pos = xPos + 1; |
| | |
| | | return ret; |
| | | } |
| | | |
| | | boolean isPositionalSpecification() |
| | | { |
| | | boolean isPositionalSpecification() { |
| | | return positionalSpecification; |
| | | } |
| | | |
| | | int getArgumentPosition() |
| | | { |
| | | int getArgumentPosition() { |
| | | return argumentPosition; |
| | | } |
| | | |
| | | boolean isPositionalFieldWidth() |
| | | { |
| | | boolean isPositionalFieldWidth() { |
| | | return positionalFieldWidth; |
| | | } |
| | | |
| | | int getArgumentPositionForFieldWidth() |
| | | { |
| | | int getArgumentPositionForFieldWidth() { |
| | | return argumentPositionForFieldWidth; |
| | | } |
| | | |
| | | boolean isPositionalPrecision() |
| | | { |
| | | boolean isPositionalPrecision() { |
| | | return positionalPrecision; |
| | | } |
| | | |
| | | int getArgumentPositionForPrecision() |
| | | { |
| | | int getArgumentPositionForPrecision() { |
| | | return argumentPositionForPrecision; |
| | | } |
| | | |
| | | /** |
| | | * Set flag characters, one of '-+#0 or a space. |
| | | */ |
| | | private void setFlagCharacters() |
| | | { |
| | | private void setFlagCharacters() { |
| | | /* '-+ #0 */ |
| | | thousands = false; |
| | | leftJustify = false; |
| | |
| | | alternateForm = false; |
| | | leadingZeros = false; |
| | | |
| | | for (; pos < fmt.length(); pos++) |
| | | { |
| | | for (; pos < fmt.length(); pos++) { |
| | | char c = fmt.charAt(pos); |
| | | |
| | | if (c == '\'') |
| | | { |
| | | if (c == '\'') { |
| | | thousands = true; |
| | | } else if (c == '-') |
| | | { |
| | | } else if (c == '-') { |
| | | leftJustify = true; |
| | | leadingZeros = false; |
| | | } else if (c == '+') |
| | | { |
| | | } else if (c == '+') { |
| | | leadingSign = true; |
| | | leadingSpace = false; |
| | | } else if (c == ' ') |
| | | { |
| | | if (!leadingSign) |
| | | { |
| | | } else if (c == ' ') { |
| | | if (!leadingSign) { |
| | | leadingSpace = true; |
| | | } |
| | | } else if (c == '#') |
| | | { |
| | | } else if (c == '#') { |
| | | alternateForm = true; |
| | | } else if (c == '0') |
| | | { |
| | | if (!leftJustify) |
| | | { |
| | | } else if (c == '0') { |
| | | if (!leftJustify) { |
| | | leadingZeros = true; |
| | | } |
| | | } else |
| | | { |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | |
| | | * Dgn7OracleReaderTest |
| | | * User: Ulysses |
| | | * Date: 2007/10/24 |
| | | * Time: ¤W¤È 10:49:54 |
| | | */ |
| | | public class Dgn7OracleReaderTest |
| | | { |
| | | public class Dgn7OracleReaderTest { |
| | | @BeforeTest |
| | | public void setUp() |
| | | { |
| | | public void setUp() { |
| | | |
| | | } |
| | | |
| | | @Test |
| | | public void testOracleReader() throws SQLException, IOException |
| | | { |
| | | // @Test |
| | | public void testOracleReader() throws SQLException, IOException { |
| | | OracleConnection connection = OracleTarget.getInstance().getOracleConnection(); |
| | | // String fetchSrcStmtFmt = "SELECT IGDSELM FROM \"%s\".\"%s\" ORDER BY ROWID"; |
| | | String fetchSrcStmtFmt = "SELECT IGDSELM FROM \"%s\".\"%s\" WHERE TAG_SFSC=106 ORDER BY ROWID"; |
| | |
| | | |
| | | Dgn7OracleReader reader = new Dgn7OracleReader(fetchSrcStmt, "IGDSELM", connection); |
| | | int count = 0; |
| | | while (reader.hasNext()) |
| | | { |
| | | while (reader.hasNext()) { |
| | | Element element = reader.next(); |
| | | |
| | | if (element instanceof ComplexChainElement) |
| | | { |
| | | if (element instanceof ComplexChainElement) { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | FrammeAttributeData frammeLinkage = null; |
| | | |
| | | List<UserAttributeData> attrs = complexChain.getUserAttributeData(); |
| | | for (int k = 0; k < attrs.size(); k++) |
| | | { |
| | | for (int k = 0; k < attrs.size(); k++) { |
| | | UserAttributeData userAttr = attrs.get(k); |
| | | if (userAttr instanceof FrammeAttributeData) |
| | | { |
| | | if (userAttr instanceof FrammeAttributeData) { |
| | | frammeLinkage = (FrammeAttributeData) userAttr; |
| | | break; |
| | | } |
| | |
| | | else |
| | | System.out.print("Linkage is null"); |
| | | |
| | | for (int i = 0; i < complexChain.size(); i++) |
| | | { |
| | | for (int i = 0; i < complexChain.size(); i++) { |
| | | Element elm = (Element) complexChain.get(i); |
| | | if (elm instanceof LineStringElement) |
| | | { |
| | | if (elm instanceof LineStringElement) { |
| | | LineStringElement lineStringElement = (LineStringElement) elm; |
| | | int size = lineStringElement.getVerticeSize(); |
| | | System.out.print("size=" + size + ":"); |
| | |
| | | } |
| | | |
| | | System.out.println(); |
| | | } else if (element instanceof TextNodeElement) |
| | | { |
| | | } else if (element instanceof TextNodeElement) { |
| | | TextNodeElement textNode = (TextNodeElement) element; |
| | | |
| | | FrammeAttributeData frammeLinkage = null; |
| | | |
| | | List<UserAttributeData> attrs = textNode.getUserAttributeData(); |
| | | for (int k = 0; k < attrs.size(); k++) |
| | | { |
| | | for (int k = 0; k < attrs.size(); k++) { |
| | | UserAttributeData userAttr = attrs.get(k); |
| | | if (userAttr instanceof FrammeAttributeData) |
| | | { |
| | | if (userAttr instanceof FrammeAttributeData) { |
| | | frammeLinkage = (FrammeAttributeData) userAttr; |
| | | break; |
| | | } |
| | |
| | | ":COMP-" + frammeLinkage.getComponentID()); |
| | | else |
| | | System.out.print("Linkage is null"); |
| | | for (int i = 0; i < textNode.size(); i++) |
| | | { |
| | | for (int i = 0; i < textNode.size(); i++) { |
| | | Element elm = (Element) textNode.get(i); |
| | | if (elm instanceof TextElement) |
| | | { |
| | | if (elm instanceof TextElement) { |
| | | TextElement textElm = (TextElement) elm; |
| | | System.out.print("---"); |
| | | String text = textElm.getText(); |
| | |
| | | * Dgn7TextElementReaderTest |
| | | * User: Ulysses |
| | | * Date: 2008/1/10 |
| | | * Time: ¤W¤È 12:19:14 |
| | | */ |
| | | public class Dgn7TextElementReaderTest |
| | | { |
| | | public class Dgn7TextElementReaderTest { |
| | | private final static Logger logger = Logger.getLogger(Dgn7fileReaderTest.class); |
| | | |
| | | private final static String testFilePathCreated = "demo.dgn"; |
| | |
| | | private FileInputStream _fs; |
| | | |
| | | @BeforeTest |
| | | public void setUp() throws FileNotFoundException |
| | | { |
| | | public void setUp() throws FileNotFoundException { |
| | | } |
| | | |
| | | @Test |
| | | public void testRead() throws Dgn7fileException, IOException |
| | | { |
| | | public void testRead() throws Dgn7fileException, IOException { |
| | | File dataFile = TestData.file(this, testFilePathCreated); |
| | | if (dataFile.exists()) |
| | | { |
| | | if (dataFile.exists()) { |
| | | System.out.println("Output--" + testFilePathCreated); |
| | | _fs = new FileInputStream(dataFile); |
| | | FileChannel fc = _fs.getChannel(); |
| | |
| | | } |
| | | |
| | | dataFile = TestData.file(this, testFilePathExist); |
| | | if (dataFile.exists()) |
| | | { |
| | | if (dataFile.exists()) { |
| | | System.out.println("Output--" + testFilePathExist); |
| | | _fs = new FileInputStream(dataFile); |
| | | FileChannel fc = _fs.getChannel(); |
| | |
| | | } |
| | | |
| | | dataFile = TestData.file(this, testFilePathPostComplete); |
| | | if (dataFile.exists()) |
| | | { |
| | | if (dataFile.exists()) { |
| | | System.out.println("Output--" + testFilePathPostComplete); |
| | | _fs = new FileInputStream(dataFile); |
| | | FileChannel fc = _fs.getChannel(); |
| | |
| | | } |
| | | } |
| | | |
| | | public void dumpElements(FileChannel fc) throws Dgn7fileException, IOException |
| | | { |
| | | public void dumpElements(FileChannel fc) throws Dgn7fileException, IOException { |
| | | Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock()); |
| | | int count = 0; |
| | | Element lastComplex = null; |
| | | while (reader.hasNext()) |
| | | { |
| | | Dgn7fileReader.Record record = reader.nextElement(); |
| | | if (record.element() != null) |
| | | { |
| | | while (reader.hasNext()) { |
| | | Element.FileRecord record = reader.nextElement(); |
| | | if (record.element() != null) { |
| | | Element element = (Element) record.element(); |
| | | ElementType type = element.getElementType(); |
| | | |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) { |
| | | if (lastComplex != null) { |
| | | // @todo add process in here |
| | | lastComplex = null; |
| | | } |
| | | |
| | | // @todo add process in here |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | } else if (element.isComponentElement()) { |
| | | if (lastComplex != null) { |
| | | ((ComplexElement) lastComplex).add(element); |
| | | } |
| | | } else if (type.isComplexElement()) |
| | | { |
| | | if (lastComplex == null) |
| | | { |
| | | } else if (type.isComplexElement()) { |
| | | if (lastComplex == null) { |
| | | lastComplex = element; |
| | | } else |
| | | { |
| | | } else { |
| | | // @todo add process in here |
| | | lastComplex = element; |
| | | } |
| | | } |
| | | |
| | | if (element.getElementType().isComplexElement()) |
| | | { |
| | | if (element instanceof ComplexChainElement) |
| | | { |
| | | if (element.getElementType().isComplexElement()) { |
| | | if (element instanceof ComplexChainElement) { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | int size = complexChain.size(); |
| | | for (Object aComplexChain : complexChain) |
| | | { |
| | | for (Object aComplexChain : complexChain) { |
| | | Element subElement = (Element) aComplexChain; |
| | | subElement.getType(); |
| | | } |
| | | } |
| | | |
| | | if (element instanceof ComplexShapeElement) |
| | | { |
| | | if (element instanceof ComplexShapeElement) { |
| | | ComplexShapeElement complexShape = (ComplexShapeElement) element; |
| | | } |
| | | |
| | | if (element instanceof TextNodeElement) |
| | | { |
| | | if (element instanceof TextNodeElement) { |
| | | TextNodeElement textNode = (TextNodeElement) element; |
| | | int size = textNode.size(); |
| | | for (int i = 0; i < size; i++) |
| | | { |
| | | for (int i = 0; i < size; i++) { |
| | | Element subElement = (Element) textNode.get(i); |
| | | subElement.getElementType(); |
| | | } |
| | | } |
| | | |
| | | } else |
| | | { |
| | | } else { |
| | | boolean hasLinkage = false; |
| | | if (element instanceof TextElement) |
| | | { |
| | | if (element instanceof TextElement) { |
| | | TextElement textElm = (TextElement) element; |
| | | List<UserAttributeData> usrData = textElm.getUserAttributeData(); |
| | | Iterator<UserAttributeData> it = usrData.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | while (it.hasNext()) { |
| | | UserAttributeData attr = it.next(); |
| | | if (attr instanceof FrammeAttributeData) |
| | | { |
| | | if (attr instanceof FrammeAttributeData) { |
| | | hasLinkage = true; |
| | | System.out.println("------------------------------------------"); |
| | | System.out.println("FSC=" + ((FrammeAttributeData) attr).getFsc() + ":" + |
| | |
| | | } |
| | | } |
| | | |
| | | if (hasLinkage) |
| | | { |
| | | if (hasLinkage) { |
| | | System.out.println("Text.Font=" + textElm.getFontIndex()); |
| | | System.out.println("Text.Just=" + textElm.getJustification()); |
| | | System.out.println("usrData.len=" + usrData.size()); |
| | |
| | | count++; |
| | | } |
| | | |
| | | logger.info("ElementRecord Count=" + count); |
| | | logger.info("FileRecord Count=" + count); |
| | | } |
| | | } |
| | |
| | | * Dgn7fileReaderTest |
| | | * User: Ulysses |
| | | * Date: 2007/10/24 |
| | | * Time: ¤W¤È 01:43:41 |
| | | * Time: �W�� 01:43:41 |
| | | * To change this template use File | Settings | File Templates. |
| | | */ |
| | | public class Dgn7fileReaderTest |
| | | { |
| | | public class Dgn7fileReaderTest { |
| | | private final static Logger logger = Logger.getLogger(Dgn7fileReaderTest.class); |
| | | |
| | | // private final static String testFilePath = "test-data\\testHV.dgn"; |
| | |
| | | private FileInputStream _fs; |
| | | |
| | | @BeforeTest |
| | | public void setUp() throws IOException |
| | | { |
| | | public void setUp() throws IOException { |
| | | File dataFile = TestData.file(this, testFilePath); |
| | | if (!dataFile.exists()) |
| | | { |
| | | if (!dataFile.exists()) { |
| | | return; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testRead() throws Dgn7fileException, IOException |
| | | { |
| | | public void testRead() throws Dgn7fileException, IOException { |
| | | if (_fs == null) return; |
| | | FileChannel fc = _fs.getChannel(); |
| | | Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock()); |
| | | int count = 0; |
| | | Element lastComplex = null; |
| | | while (reader.hasNext()) |
| | | { |
| | | Dgn7fileReader.Record record = reader.nextElement(); |
| | | if (record.element() != null) |
| | | { |
| | | while (reader.hasNext()) { |
| | | Element.FileRecord record = reader.nextElement(); |
| | | if (record.element() != null) { |
| | | Element element = (Element) record.element(); |
| | | ElementType type = element.getElementType(); |
| | | |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) { |
| | | if (lastComplex != null) { |
| | | // @todo add process in here |
| | | lastComplex = null; |
| | | } |
| | | |
| | | // @todo add process in here |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | } else if (element.isComponentElement()) { |
| | | if (lastComplex != null) { |
| | | ((ComplexElement) lastComplex).add(element); |
| | | } |
| | | } else if (type.isComplexElement()) |
| | | { |
| | | if (lastComplex == null) |
| | | { |
| | | } else if (type.isComplexElement()) { |
| | | if (lastComplex == null) { |
| | | lastComplex = element; |
| | | } else |
| | | { |
| | | } else { |
| | | // @todo add process in here |
| | | lastComplex = element; |
| | | } |
| | | } |
| | | |
| | | if (element.getElementType().isComplexElement()) |
| | | { |
| | | if (element instanceof ComplexChainElement) |
| | | { |
| | | if (element.getElementType().isComplexElement()) { |
| | | if (element instanceof ComplexChainElement) { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | int size = complexChain.size(); |
| | | for (Object aComplexChain : complexChain) |
| | | { |
| | | for (Object aComplexChain : complexChain) { |
| | | Element subElement = (Element) aComplexChain; |
| | | subElement.getType(); |
| | | } |
| | | } |
| | | |
| | | if (element instanceof ComplexShapeElement) |
| | | { |
| | | if (element instanceof ComplexShapeElement) { |
| | | ComplexShapeElement complexShape = (ComplexShapeElement) element; |
| | | } |
| | | |
| | | if (element instanceof TextNodeElement) |
| | | { |
| | | if (element instanceof TextNodeElement) { |
| | | TextNodeElement textNode = (TextNodeElement) element; |
| | | int size = textNode.size(); |
| | | for (int i = 0; i < size; i++) |
| | | { |
| | | for (int i = 0; i < size; i++) { |
| | | Element subElement = (Element) textNode.get(i); |
| | | subElement.getElementType(); |
| | | } |
| | |
| | | count++; |
| | | } |
| | | |
| | | logger.info("ElementRecord Count=" + count); |
| | | logger.info("FileRecord Count=" + count); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ximple.io.dgn7;
|
| | |
|
| | | import org.apache.commons.io.FileUtils;
|
| | | import org.apache.log4j.Logger;
|
| | | import org.geotools.TestData;
|
| | | import org.testng.Assert;
|
| | | import org.testng.annotations.BeforeTest;
|
| | | import org.testng.annotations.Test;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.FileOutputStream;
|
| | | import java.io.IOException;
|
| | | import java.io.RandomAccessFile;
|
| | | import java.nio.channels.FileChannel;
|
| | |
|
| | | public class Dgn7fileWriterTest {
|
| | | private final static Logger logger = Logger.getLogger(Dgn7fileReaderTest.class);
|
| | |
|
| | | // private final static String testFilePath = "test-data\\testHV.dgn";
|
| | | private final static String testFilePath = "testHV.dgn";
|
| | | private FileInputStream _fs;
|
| | |
|
| | | @BeforeTest
|
| | | public void setUp() throws IOException {
|
| | | File dataFile = TestData.file(this, testFilePath);
|
| | | if (!dataFile.exists()) {
|
| | | return;
|
| | | }
|
| | |
|
| | | _fs = new FileInputStream(dataFile);
|
| | | }
|
| | | |
| | | @Test
|
| | | public void testWrite() {
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void testCopy() throws Dgn7fileException, IOException {
|
| | | File target = TestData.temp(this, "testdgn2d.dgn");
|
| | | FileUtils.copyFile(TestData.file(this, "dgnseed2d.dgn"), target);
|
| | | RandomAccessFile targetStream = new RandomAccessFile(target, "rw");
|
| | | FileChannel fctarget = targetStream.getChannel();
|
| | | Lock lock = new Lock();
|
| | |
|
| | | Dgn7fileReader targetReader = new Dgn7fileReader(fctarget, new Lock());
|
| | | while (targetReader.hasNext()) {
|
| | | targetReader.nextElement();
|
| | | }
|
| | |
|
| | | Dgn7fileWriter writer = new Dgn7fileWriter(fctarget, lock);
|
| | |
|
| | | FileChannel fc = _fs.getChannel();
|
| | | Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock());
|
| | | int count = 0;
|
| | | Element lastComplex = null;
|
| | | while (reader.hasNext()) {
|
| | | Element.FileRecord record = reader.nextElement();
|
| | | if (record.element() != null) {
|
| | | Element element = (Element) record.element();
|
| | | ElementType type = element.getElementType();
|
| | | boolean completed = false;
|
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) {
|
| | | if (lastComplex != null) {
|
| | | // @todo add process in here
|
| | | processCompleteElement(lastComplex, writer);
|
| | | lastComplex = null;
|
| | | }
|
| | |
|
| | | // @todo add process in here
|
| | | processCompleteElement(element, writer);
|
| | | } else if (element.isComponentElement()) {
|
| | | if (lastComplex != null) {
|
| | | ((ComplexElement) lastComplex).add(element);
|
| | | } else {
|
| | | logger.warn("wong." + element.toString());
|
| | | Assert.fail("Component Element cannot found parent.");
|
| | | }
|
| | | } else if (type.isComplexElement()) {
|
| | | if (lastComplex != null) {
|
| | | // @todo add process in here
|
| | | processCompleteElement(lastComplex, writer);
|
| | | }
|
| | | lastComplex = element;
|
| | | }
|
| | | // writer.writeElement(element);
|
| | | }
|
| | | count++;
|
| | | }
|
| | | writer.writeEOF();
|
| | | writer.close();
|
| | |
|
| | | // FileUtils.copyFile(target, new File("G://target.dgn"));
|
| | | }
|
| | |
|
| | | private boolean processCompleteElement(Element element, Dgn7fileWriter writer) throws IOException {
|
| | | writer.writeElement(element);
|
| | | return true;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.ximple.io.dgn7;
|
| | |
|
| | | import com.vividsolutions.jts.geom.CoordinateList;
|
| | | import com.vividsolutions.jts.geom.GeometryFactory;
|
| | | import com.vividsolutions.jts.geom.LineString;
|
| | | import com.vividsolutions.jts.geom.MultiLineString;
|
| | | import org.apache.commons.io.FileUtils;
|
| | | import org.apache.log4j.Logger;
|
| | | import org.geotools.TestData;
|
| | | import org.testng.Assert;
|
| | | import org.testng.annotations.BeforeTest;
|
| | | import org.testng.annotations.Test;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.IOException;
|
| | | import java.io.RandomAccessFile;
|
| | | import java.nio.channels.FileChannel;
|
| | |
|
| | | /**
|
| | | * Created by IntelliJ IDEA.
|
| | | * User: Ulysses
|
| | | * Date: 2010/4/21
|
| | | */
|
| | | public class ElementFactoryTest {
|
| | | private final static Logger logger = Logger.getLogger(Dgn7fileReaderTest.class);
|
| | |
|
| | | // private final static String testFilePath = "test-data\\testHV.dgn";
|
| | | private final static String testFilePath = "testHV.dgn";
|
| | |
|
| | | private static GeometryFactory factory = new GeometryFactory();
|
| | |
|
| | | private FileInputStream _fs;
|
| | | private LineStringElement _testLineString = null;
|
| | | private ComplexChainElement _testComplexChain = null;
|
| | |
|
| | | @BeforeTest
|
| | | public void setUp() throws IOException, Dgn7fileException {
|
| | | File dataFile = TestData.file(this, testFilePath);
|
| | | if (!dataFile.exists()) {
|
| | | return;
|
| | | }
|
| | |
|
| | | _fs = new FileInputStream(dataFile);
|
| | |
|
| | | fetchTestElement(_fs);
|
| | | _fs.close();
|
| | | }
|
| | |
|
| | | private void fetchTestElement(FileInputStream fs) throws Dgn7fileException, IOException {
|
| | | FileChannel fc = _fs.getChannel();
|
| | | Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock());
|
| | | int count = 0;
|
| | | Element lastComplex = null;
|
| | | while (reader.hasNext()) {
|
| | | Element.FileRecord record = reader.nextElement();
|
| | | if (record.element() != null) {
|
| | | Element element = (Element) record.element();
|
| | | ElementType type = element.getElementType();
|
| | | boolean completed = false;
|
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) {
|
| | | if (lastComplex != null) {
|
| | | // @todo add process in here
|
| | | if (!processCompleteElement(lastComplex)) break;
|
| | | lastComplex = null;
|
| | | }
|
| | |
|
| | | // @todo add process in here
|
| | | if (!processCompleteElement(element)) break;
|
| | | } else if (element.isComponentElement()) {
|
| | | if (lastComplex != null) {
|
| | | ((ComplexElement) lastComplex).add(element);
|
| | | } else {
|
| | | logger.warn("wong." + element.toString());
|
| | | Assert.fail("Component Element cannot found parent.");
|
| | | }
|
| | | } else if (type.isComplexElement()) {
|
| | | if (lastComplex != null) {
|
| | | // @todo add process in here
|
| | | if (!processCompleteElement(lastComplex)) break;
|
| | | }
|
| | | lastComplex = element;
|
| | | }
|
| | | }
|
| | | count++;
|
| | | }
|
| | | }
|
| | |
|
| | | private boolean processCompleteElement(Element element) throws IOException {
|
| | | if (element instanceof LineStringElement) {
|
| | | _testLineString = (LineStringElement) element;
|
| | | }
|
| | |
|
| | | if (element instanceof ComplexChainElement) {
|
| | | _testComplexChain = (ComplexChainElement) element;
|
| | | }
|
| | |
|
| | | if ((_testLineString != null) && (_testComplexChain != null)) return false;
|
| | | return true;
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void testCreateLineString() throws IOException, Dgn7fileException {
|
| | | Assert.assertNotNull(_testLineString);
|
| | | LineStringElement originElement = _testLineString;
|
| | |
|
| | | LineString geometry = (LineString) originElement.toGeometry(factory);
|
| | | Element cloneElement = ElementFactory.createLineString(geometry);
|
| | | Assert.assertTrue(cloneElement instanceof LineStringElement);
|
| | | cloneElement.setLevelIndex(originElement.getLevelIndex());
|
| | | cloneElement.setColorIndex(originElement.getColorIndex());
|
| | | cloneElement.setWeight(originElement.getWeight());
|
| | | cloneElement.setLineStyle(originElement.getLineStyle());
|
| | | cloneElement.setRange(geometry.getEnvelopeInternal());
|
| | |
|
| | | int len = originElement.raw.length;
|
| | | int lenClone = cloneElement.raw.length;
|
| | | // Assert.assertEquals(lenClone, len - originElement.getUserAttributeDataOffset() + 1);
|
| | | if (originElement.hasUserAttributeData()) {
|
| | | Assert.assertEquals(lenClone, originElement.getUserAttributeDataOffset());
|
| | | }
|
| | | System.out.println("origin size=(" + len + ")-:- Clone size=(" + lenClone + ")");
|
| | | int headerSize = ElementFactory.MINIMAL_ELEMLENGTH / 2;
|
| | | for (int i = 0; i <= headerSize; i++) {
|
| | | if (originElement.raw[i] != cloneElement.raw[i]) {
|
| | | System.out.print("different index=" + i + ":");
|
| | | System.out.println("origin[" + Integer.toHexString(originElement.raw[i])
|
| | | + "]-clone:[" + Integer.toHexString(cloneElement.raw[i]) + "]");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void testCreateComplexChain() throws IOException, Dgn7fileException {
|
| | | Assert.assertNotNull(_testComplexChain);
|
| | | ComplexChainElement originElement = _testComplexChain;
|
| | |
|
| | | System.out.print("len=" + originElement.raw.length);
|
| | | for (Element elm : originElement) {
|
| | | System.out.print(":" + elm.raw.length);
|
| | | }
|
| | | System.out.println();
|
| | |
|
| | | MultiLineString geometries = (MultiLineString) originElement.toGeometry(factory);
|
| | | LineString geometry = factory.createLineString(geometries.getCoordinates());
|
| | |
|
| | | ComplexChainElement cloneElement = (ComplexChainElement) ElementFactory.createComplexChain(geometry);
|
| | | Assert.assertTrue(cloneElement instanceof ComplexChainElement);
|
| | | cloneElement.setLevelIndex(originElement.getLevelIndex());
|
| | | cloneElement.setColorIndex(originElement.getColorIndex());
|
| | | cloneElement.setWeight(originElement.getWeight());
|
| | | cloneElement.setLineStyle(originElement.getLineStyle());
|
| | | cloneElement.setRange(geometry.getEnvelopeInternal());
|
| | |
|
| | | int len = originElement.raw.length;
|
| | | int lenClone = cloneElement.raw.length;
|
| | | // Assert.assertEquals(lenClone, len - originElement.getUserAttributeDataOffset() + 1);
|
| | | System.out.print("clonelen=" + cloneElement.raw.length);
|
| | | for (Element elm : cloneElement) {
|
| | | System.out.print(":" + elm.raw.length);
|
| | | }
|
| | | System.out.println();
|
| | |
|
| | | if (originElement.hasUserAttributeData()) {
|
| | | Assert.assertEquals(lenClone, originElement.getUserAttributeDataOffset() + 4);
|
| | | }
|
| | | System.out.println("origin size=(" + len + ")-:- Clone size=(" + lenClone + ")");
|
| | | int headerSize = ElementFactory.MINIMAL_ELEMLENGTH / 2 + 6;
|
| | | for (int i = 0; i < headerSize; i++) {
|
| | | if (originElement.raw[i] != cloneElement.raw[i]) {
|
| | | System.out.print("different index=" + i + ":");
|
| | | System.out.println("origin[" + Integer.toHexString(originElement.raw[i])
|
| | | + "]-clone:[" + Integer.toHexString(cloneElement.raw[i]) + "]");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | * Time: ?U?? 03:12:43 |
| | | * To change this template use File | Settings | File Templates. |
| | | */ |
| | | public class OracleTarget |
| | | { |
| | | public class OracleTarget { |
| | | private static final Logger logger = Logger.getLogger(OracleTarget.class); |
| | | private static OracleTarget _instance = null; |
| | | private static final String ORACLE_URL = "jdbc:oracle:thin:@"; |
| | | private static final String _propUsrKey = "user"; |
| | | private static final String _propPassKey = "password"; |
| | | private static String _oracleHost = "192.168.11.200"; |
| | | private static String _oracleInstance = "NNTPC"; |
| | | private static String _oracleHost = "10.10.1.7"; |
| | | private static String _oracleInstance = "ORCL"; |
| | | private static String _oraclePort = "1521"; |
| | | |
| | | static |
| | | { |
| | | try |
| | | { |
| | | static { |
| | | try { |
| | | DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | Assert.shouldNeverReachHere(e.getMessage()); |
| | | } |
| | | } |
| | |
| | | private OracleConnection oracleConnection = null; |
| | | private Properties properties; |
| | | |
| | | private OracleTarget() |
| | | { |
| | | private OracleTarget() { |
| | | properties = new Properties(); |
| | | properties.put(_propUsrKey, "SPATIALDB"); |
| | | properties.put(_propPassKey, "SPATIALDB000"); |
| | | properties.put(_propUsrKey, "system"); |
| | | properties.put(_propPassKey, "simple000"); |
| | | } |
| | | |
| | | public static String getOracleHost() |
| | | { |
| | | public static String getOracleHost() { |
| | | return _oracleHost; |
| | | } |
| | | |
| | | public static void setOracleHost(String oracleHost) |
| | | { |
| | | public static void setOracleHost(String oracleHost) { |
| | | OracleTarget._oracleHost = oracleHost; |
| | | } |
| | | |
| | | public static String getOracleInstance() |
| | | { |
| | | public static String getOracleInstance() { |
| | | return _oracleInstance; |
| | | } |
| | | |
| | | public static void setOracleInstance(String oracleInstance) |
| | | { |
| | | public static void setOracleInstance(String oracleInstance) { |
| | | OracleTarget._oracleInstance = oracleInstance; |
| | | } |
| | | |
| | | public static String getOraclePort() |
| | | { |
| | | public static String getOraclePort() { |
| | | return _oraclePort; |
| | | } |
| | | |
| | | public static void setOraclePort(String oraclePort) |
| | | { |
| | | public static void setOraclePort(String oraclePort) { |
| | | OracleTarget._oraclePort = oraclePort; |
| | | } |
| | | |
| | | public static String getCurrentURL() |
| | | { |
| | | public static String getCurrentURL() { |
| | | StringBuilder builder = new StringBuilder(); |
| | | |
| | | builder.append(ORACLE_URL); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | public String getLoginPass() |
| | | { |
| | | public String getLoginPass() { |
| | | return (String) properties.get(_propPassKey); |
| | | } |
| | | |
| | | public void setLoginPass(String loginPass) |
| | | { |
| | | public void setLoginPass(String loginPass) { |
| | | properties.put(_propPassKey, loginPass); |
| | | } |
| | | |
| | | public String getLoginUsr() |
| | | { |
| | | public String getLoginUsr() { |
| | | return (String) properties.get(_propUsrKey); |
| | | } |
| | | |
| | | public void setLoginUsr(String loginUsr) |
| | | { |
| | | public void setLoginUsr(String loginUsr) { |
| | | properties.put(_propUsrKey, loginUsr); |
| | | } |
| | | |
| | | public static OracleTarget getInstance() |
| | | { |
| | | if (_instance == null) |
| | | { |
| | | public static OracleTarget getInstance() { |
| | | if (_instance == null) { |
| | | _instance = new OracleTarget(); |
| | | } |
| | | |
| | | return _instance; |
| | | } |
| | | |
| | | public OracleConnection getOracleConnection() |
| | | { |
| | | try |
| | | { |
| | | if (oracleConnection == null) |
| | | { |
| | | public OracleConnection getOracleConnection() { |
| | | try { |
| | | if (oracleConnection == null) { |
| | | oracleConnection = (OracleConnection) DriverManager.getConnection(getCurrentURL(), properties); |
| | | } |
| | | |
| | | return oracleConnection; |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | public void closeConnection() |
| | | { |
| | | try |
| | | { |
| | | if (oracleConnection != null) |
| | | { |
| | | public void closeConnection() { |
| | | try { |
| | | if (oracleConnection != null) { |
| | | oracleConnection.close(); |
| | | oracleConnection = null; |
| | | } |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | } |
| | |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | |
| | | <parent> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-dgnjobs</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | </parent> |
| | | |
| | | |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-elmparser</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | <packaging>jar</packaging> |
| | | <name>ximple-elmparser</name> |
| | | <url>http://maven.apache.org</url> |
| | | |
| | | <properties> |
| | | <xdgnio.version>0.9.0</xdgnio.version> |
| | | <xdgnio.version>1.2.2</xdgnio.version> |
| | | </properties> |
| | | |
| | | <scm> |
| | |
| | | <url>http://www.ximple.com.tw</url> |
| | | </organization> |
| | | |
| | | <inceptionYear>2008</inceptionYear> |
| | | <inceptionYear>2010</inceptionYear> |
| | | |
| | | <developers> |
| | | <developer> |
| | |
| | | <!-- =========================================================== --> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.quartz-scheduler</groupId> |
| | | <artifactId>quartz</artifactId> |
| | | <groupId>opensymphony</groupId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-shapefile</artifactId> |
| | | <artifactId>gt-shapefile</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-sample-data</artifactId> |
| | | <artifactId>gt-sample-data</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-data</artifactId> |
| | | <artifactId>gt-data</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-jdbc</artifactId> |
| | | <artifactId>gt-jdbc</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-postgis</artifactId> |
| | | <artifactId>gt-postgis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-oracle-spatial</artifactId> |
| | | <artifactId>gt-oracle-spatial</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-mysql</artifactId> |
| | | <artifactId>gt-mysql</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- because main and sample-data depend on referencing we need a tie breaker --> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-referencing</artifactId> |
| | | <artifactId>gt-referencing</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- We need this to make the referencing module useful --> |
| | | <dependency> |
| | | <artifactId>gt2-epsg-hsql</artifactId> |
| | | <artifactId>gt-epsg-hsql</artifactId> |
| | | <groupId>org.geotools</groupId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.jdom</groupId> |
| | | <artifactId>jdom</artifactId> |
| | | <groupId>jdom</groupId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | |
| | | <!-- Ximple Library --> |
| | | <dependency> |
| | | <artifactId>ximple-dgnio</artifactId> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <version>${xdgnio.version}</version> |
| | | <artifactId>ximple-dgnio</artifactId> |
| | | <version>${project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <artifactId>ximple-spatialjob</artifactId> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <version>${xdgnio.version}</version> |
| | | <artifactId>ximple-spatialjob</artifactId> |
| | | <version>${project.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | |
| | | Use maven from the command line: |
| | | mvn exec:java -Dexec.mainClass="com.ximple.eofms.XElementParser" |
| | | --> |
| | | <artifactId>exec-maven-plugin</artifactId> |
| | | <groupId>org.codehaus.mojo</groupId> |
| | | <artifactId>exec-maven-plugin</artifactId> |
| | | <version>1.2.1</version> |
| | | <!-- |
| | | <executions> |
| | | <execution> |
| | |
| | | elmLogger.flashLogging(); |
| | | } |
| | | |
| | | protected static byte[] getBytesFromBLOB(BLOB blob) throws SQLException |
| | | protected byte[] getBytesFromBLOB(BLOB blob) throws SQLException |
| | | { |
| | | byte[] raw = null; |
| | | |
| | |
| | | buffer.put(chunk); |
| | | } |
| | | |
| | | is.close(); |
| | | |
| | | assert buffer != null; |
| | | buffer.position(0); |
| | | raw = buffer.array(); |
| | |
| | | { |
| | | e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. |
| | | Assert.shouldNeverReachHere(); |
| | | } finally |
| | | { |
| | | try { is.close(); } catch (IOException e) { logger.warn("InputStream cannot close", e); }; |
| | | } |
| | | |
| | | return raw; |
| | |
| | | BLOB blob = (BLOB) rsSrc.getBlob(1); |
| | | |
| | | raw = getBytesFromBLOB(blob); |
| | | blob.close(); |
| | | // blob.close(); |
| | | } else |
| | | { |
| | | raw = rsSrc.getBytes(1); |
| | |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.SimpleFeature; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.FeatureCollection; |
| | | import org.geotools.feature.FeatureCollections; |
| | | import org.geotools.data.FeatureWriter; |
| | |
| | | return; |
| | | } |
| | | |
| | | // §PÂ_¬O§_²Å©M±ø¥ó |
| | | // �P�_�O�_�ũM��� |
| | | Feature feature = elementDispatcher.execute(element, false); |
| | | if (feature == null) |
| | | { |
New file |
| | |
| | | # Create stdout appender
|
| | | log4j.rootLogger=info, logfile, stdout
|
| | |
|
| | | # Configure the stdout appender to go to the Console
|
| | | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
| | |
|
| | | # Configure stdout appender to use the PatternLayout
|
| | | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
| | |
|
| | | # Pattern output the caller's filename and line #
|
| | | log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
|
| | | #log4j.appender.stdout.encoding=UTF-8
|
| | |
|
| | | log4j.appender.logfile=org.apache.log4j.FileAppender
|
| | | log4j.appender.logfile.file=xjobcarrier.log
|
| | | log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
|
| | | log4j.appender.logfile.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
|
| | | #log4j.appender.logfile.encoding=UTF-8
|
| | |
|
| | | log4j.appender.remoteout=com.holub.log4j.RemoteAppender
|
| | | log4j.appender.remoteout.Port=8011
|
| | | log4j.appender.remoteout.layout=org.apache.log4j.PatternLayout
|
| | | log4j.appender.remoteout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
|
| | | #log4j.appender.remoteout.encoding=UTF-8
|
| | |
|
| | | # Print messages of level INFO or above for examples
|
| | | log4j.logger.org.cavaness.quartzbook=INFO
|
| | | log4j.logger.org.quartz=DEBUG
|
| | | log4j.logger.com.ximple.eofms=DEBUG |
| | |
| | | <parent> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-dgnjobs</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | </parent> |
| | | |
| | | |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-jobcarrier</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | <packaging>jar</packaging> |
| | | <name>ximple-jobcarrier</name> |
| | | <url>http://maven.apache.org</url> |
| | | |
| | | <properties> |
| | | <xdgnio.version>0.9.0</xdgnio.version> |
| | | <xdgnio.version>2.1.1</xdgnio.version> |
| | | </properties> |
| | | |
| | | <scm> |
| | |
| | | <url>http://www.ximple.com.tw</url> |
| | | </organization> |
| | | |
| | | <inceptionYear>2008</inceptionYear> |
| | | <inceptionYear>2012</inceptionYear> |
| | | |
| | | <developers> |
| | | <developer> |
| | |
| | | <contributors> |
| | | </contributors> |
| | | |
| | | <profiles> |
| | | <profile> |
| | | <id>qa</id> |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <artifactId>maven-dependency-plugin</artifactId> |
| | | <executions> |
| | | <execution> |
| | | <phase>install</phase> |
| | | <goals> |
| | | <goal>copy-dependencies</goal> |
| | | </goals> |
| | | <configuration> |
| | | <outputDirectory>${project.build.directory}/lib</outputDirectory> |
| | | </configuration> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | </profile> |
| | | </profiles> |
| | | |
| | | <!-- =========================================================== --> |
| | | <!-- Dependencies to be inherited by all modules. --> |
| | | <!-- =========================================================== --> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.quartz-scheduler</groupId> |
| | | <artifactId>quartz</artifactId> |
| | | <groupId>opensymphony</groupId> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-api</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.quartz-scheduler</groupId> |
| | | <artifactId>quartz-jobs</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-api</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-log4j12</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>jcl-over-slf4j</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-shapefile</artifactId> |
| | | <artifactId>gt-shapefile</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-sample-data</artifactId> |
| | | <artifactId>gt-sample-data</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-data</artifactId> |
| | | <artifactId>gt-data</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-jdbc</artifactId> |
| | | <artifactId>gt-opengis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-postgis</artifactId> |
| | | <artifactId>gt-jdbc</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools.jdbc</groupId> |
| | | <artifactId>gt-jdbc-postgis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools.jdbc</groupId> |
| | | <artifactId>gt-jdbc-oracle</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools.jdbc</groupId> |
| | | <artifactId>gt-jdbc-mysql</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-oracle-spatial</artifactId> |
| | | <artifactId>gt-opengis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-mysql</artifactId> |
| | | <artifactId>gt-metadata</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- because main and sample-data depend on referencing we need a tie breaker --> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-referencing</artifactId> |
| | | <artifactId>gt-referencing</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- We need this to make the referencing module useful --> |
| | | <dependency> |
| | | <artifactId>gt2-epsg-hsql</artifactId> |
| | | <groupId>org.geotools</groupId> |
| | | <scope>test</scope> |
| | | <artifactId>gt-epsg-wkt</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <artifactId>jdom</artifactId> |
| | | <groupId>jdom</groupId> |
| | | <groupId>org.jdom</groupId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | <artifactId>sdoutl</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <!--dependency> |
| | | <groupId>postgresql</groupId> |
| | | <artifactId>postgresql</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.postgis</groupId> |
| | | <artifactId>postgis-driver</artifactId> |
| | | </dependency> |
| | | </dependency--> |
| | | |
| | | <dependency> |
| | | <!--dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | </dependency> |
| | | </dependency--> |
| | | |
| | | <!-- AWL --> |
| | | <dependency> |
| | | <groupId>org.awl</groupId> |
| | | <artifactId>awl</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>xml-apis</groupId> |
| | | <artifactId>xml-apis</artifactId> |
| | | <version>1.4.01</version> |
| | | </dependency> |
| | | |
| | | <!-- Ximple Library --> |
| | |
| | | <dependency> |
| | | <artifactId>ximple-spatialjob</artifactId> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <version>${xdgnio.version}</version> |
| | | <version>${project.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | |
| | | Use maven from the command line: |
| | | mvn exec:java -Dexec.mainClass="com.ximple.eofms.XQuartzJobCarrier" |
| | | --> |
| | | <artifactId>exec-maven-plugin</artifactId> |
| | | <groupId>org.codehaus.mojo</groupId> |
| | | <!-- |
| | | <artifactId>exec-maven-plugin</artifactId> |
| | | <version>1.2.1</version> |
| | | <executions> |
| | | <execution> |
| | | <phase>package</phase> |
| | | <!--<phase>package</phase> --> |
| | | <goals> |
| | | <goal>run</goal> |
| | | <goal>java</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | --> |
| | | <configuration> |
| | | <mainClass>com.ximple.eofms.XQuartzJobCarrier</mainClass> |
| | | <!-- |
| | | <commandlineArgs>-wizard</commandlineArgs> |
| | | <commandlineArgs>-Dlog4j.configuration=log4j.properties</commandlineArgs> |
| | | --> |
| | | <systemProperties> |
| | | <systemProperty> |
| | | <key>log4j.configuration</key> |
| | | <value>log4j.properties</value> |
| | | </systemProperty> |
| | | </systemProperties> |
| | | </configuration> |
| | | <!-- |
| | | <dependencies> |
| | |
| | | <plugin> |
| | | <groupId>org.codehaus.mojo</groupId> |
| | | <artifactId>native2ascii-maven-plugin</artifactId> |
| | | <version>1.0-alpha-1</version> |
| | | <version>1.0-beta-1</version> |
| | | <configuration> |
| | | <dest>target/classes/com/ximple/eofms</dest> |
| | | <src>src/main/resources/com/ximple/eofms</src> |
| | |
| | | </goals> |
| | | <configuration> |
| | | <encoding>UTF8</encoding> |
| | | <includes>XQuartzJobWizard_zh*.properties</includes> |
| | | <includes> |
| | | <include>XQuartzJobWizard_zh*.properties</include> |
| | | </includes> |
| | | </configuration> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | </plugins> |
| | | <resources> |
| | | <!-- |
| | | <resource> |
| | | <directory>src/main/resources/com/ximple/eofms</directory> |
| | | <excludes> |
| | |
| | | </excludes> |
| | | <filtering>true</filtering> |
| | | </resource> |
| | | --> |
| | | <resource> |
| | | <directory>src/main/resources</directory> |
| | | <includes> |
| | | <include>log4j.properties</include> |
| | | <include>quartz.properties</include> |
| | | <include>quartz_jobs.xml</include> |
| | | <include>quartz_jobs_edb.xml</include> |
| | | <include>quartz_jobs_sharpefiles.xml</include> |
| | | </includes> |
| | | <!-- |
| | | <excludes> |
| | | <exclude>log4j.properties</exclude> |
| | | <exclude>quartz_jobs.xml</exclude> |
| | | </excludes> |
| | | --> |
| | | <!-- |
| | | <excludes> |
| | | <exclude>XQuartzJobWizard*.properties</exclude> |
| | | <exclude>quartz_jobs.xml</exclude> |
| | | <exclude>quartz_jobs_shapefiles.xml</exclude> |
New file |
| | |
| | | #===============================================================
|
| | | #Configure Main Scheduler Properties
|
| | | #===============================================================
|
| | | org.quartz.scheduler.instanceName = QuartzScheduler
|
| | | org.quartz.scheduler.instanceId = AUTO
|
| | |
|
| | | #===============================================================
|
| | | #Configure ThreadPool
|
| | | #===============================================================
|
| | | org.quartz.threadPool.threadCount = 5
|
| | | org.quartz.threadPool.threadPriority = 5
|
| | | org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
|
| | |
|
| | | #===============================================================
|
| | | #Configure JobStore
|
| | | #===============================================================
|
| | | org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
|
| | | org.quartz.jobStore.misfireThreshold = 60000
|
| | |
|
| | | #===============================================================
|
| | | #Configure Plugins
|
| | | #===============================================================
|
| | | org.quartz.plugin.triggHistory.class = org.quartz.plugins.history.LoggingJobHistoryPlugin
|
| | |
|
| | | org.quartz.plugin.jobInitializer.class: org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
|
| | | org.quartz.plugin.jobInitializer.fileNames = quartz_jobs.xml
|
| | | #org.quartz.plugin.jobInitializer.fileNames = quartz_jobs_edb.xml
|
| | | org.quartz.plugin.jobInitializer.failOnFileNotFound = true
|
| | | org.quartz.plugin.jobInitializer.scanInterval = 10
|
| | | org.quartz.plugin.jobInitializer.wrapInUserTransaction = false
|
| | |
|
| | | org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin
|
| | | org.quartz.plugin.shutdownhook.cleanShutdown = true |
New file |
| | |
| | | <?xml version='1.0' encoding='utf-8'?> |
| | | |
| | | <job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd" |
| | | version="1.8"> |
| | | |
| | | <pre-processing-commands> |
| | | <delete-jobs-in-group>*</delete-jobs-in-group> <!-- clear all jobs in scheduler --> |
| | | <delete-triggers-in-group>*</delete-triggers-in-group> <!-- clear all triggers in scheduler --> |
| | | </pre-processing-commands> |
| | | |
| | | <processing-directives> |
| | | <!-- if there are any jobs/trigger in scheduler of same name (as in this file), overwrite them --> |
| | | <overwrite-existing-data>true</overwrite-existing-data> |
| | | <!-- if there are any jobs/trigger in scheduler of same name (as in this file), and over-write is false, ignore them rather then generating an error --> |
| | | <ignore-duplicates>false</ignore-duplicates> |
| | | </processing-directives> |
| | | |
| | | <schedule> |
| | | <job> |
| | | <name>ConvertDMMS2PostGisWithGeoserver</name> |
| | | <group>DEFAULT</group> |
| | | <description>A job that convert dgn to postgis</description> |
| | | <!--job-class>com.ximple.eofms.jobs.OracleConvertDgn2PostGISJob</job-class--> |
| | | <job-class>com.ximple.eofms.jobs.GeoserverIntegrateConfigJob</job-class> |
| | | <!--volatility>false</volatility--> |
| | | <durability>false</durability> |
| | | <recover>false</recover> |
| | | <!--job-data-map allows-transient-data="true"--> |
| | | <job-data-map> |
| | | <entry> |
| | | <key>JOBDATA_DIR</key> |
| | | <!--value>/Users/Shared/Public/Projects/XGeoDMMS/xjobrun/nstpcjobs/jobdata</value--> |
| | | <value>/mnt/hdisk/home.data/private/projects/xdcad/xjobrun/nntpcjobs/jobdata</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGHOST</key> |
| | | <value>192.168.11.99</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGDATBASE</key> |
| | | <value>pgNNTPC</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGPORT</key> |
| | | <value>5432</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGSCHEMA</key> |
| | | <value>public</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGUSER</key> |
| | | <value>tpcdb</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGPASS</key> |
| | | <value>simple000</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORAHOST</key> |
| | | <value>10.10.1.7</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORAINST</key> |
| | | <value>orcl</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORAPORT</key> |
| | | <value>1521</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORAUSER</key> |
| | | <value>system</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORAPASS</key> |
| | | <value>simple000</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORGSCHEMA</key> |
| | | <!--value>SPATIALDB</value--> |
| | | <value>SPATIALDB, CMMS_SPATIALDB</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CONVERTDB</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CONVERTFILE</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CONVERTELEMIN</key> |
| | | <value>false</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CREATEDUMMY</key> |
| | | <value>false</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ELEMLOG</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>USEWKB</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>TESTMODE</key> |
| | | <value>false</value> |
| | | </entry> |
| | | <entry> |
| | | <key>TESTCOUNT</key> |
| | | <value>2</value> |
| | | </entry> |
| | | <entry> |
| | | <key>COPYCONNECTIVITYMODE</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PROFILEMODE</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>USEZONE121</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>GEOSERVER_URL</key> |
| | | <value>http://192.168.11.99:8080/geoserver</value> |
| | | </entry> |
| | | <entry> |
| | | <key>GEOSERVER_USER</key> |
| | | <value>admin</value> |
| | | </entry> |
| | | <entry> |
| | | <key>GEOSERVER_PASS</key> |
| | | <value>geoserver</value> |
| | | </entry> |
| | | <entry> |
| | | <key>IGNORE_DBETL</key> |
| | | <value>false</value> |
| | | </entry> |
| | | </job-data-map> |
| | | </job> |
| | | |
| | | <trigger> |
| | | <simple> |
| | | <name>convertTrigger</name> |
| | | <group>DEFAULT</group> |
| | | <job-name>ConvertDMMS2PostGisWithGeoserver</job-name> |
| | | <job-group>DEFAULT</job-group> |
| | | <start-time>2013-03-01T18:00:00</start-time> |
| | | <!-- repeat indefinitely every 10 seconds --> |
| | | <repeat-count>0</repeat-count> |
| | | <repeat-interval>500</repeat-interval> |
| | | <!-- <repeat-interval>72000000</repeat-interval> --> |
| | | </simple> |
| | | </trigger> |
| | | |
| | | </schedule> |
| | | |
| | | </job-scheduling-data> |
| | |
| | | package com.ximple.eofms; |
| | | |
| | | import java.util.Date; |
| | | import javax.swing.JFrame; |
| | | import javax.swing.SwingUtilities; |
| | | import java.util.Date; |
| | | |
| | | import org.apache.commons.cli.CommandLine; |
| | | import org.apache.commons.cli.CommandLineParser; |
| | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.awl.Wizard; |
| | | import org.quartz.DateBuilder; |
| | | import org.quartz.JobBuilder; |
| | | import org.quartz.JobDetail; |
| | | import org.quartz.Scheduler; |
| | | import org.quartz.SchedulerException; |
| | | import org.quartz.Trigger; |
| | | import org.quartz.TriggerBuilder; |
| | | import org.quartz.TriggerUtils; |
| | | import org.quartz.impl.JobDetailImpl; |
| | | import org.quartz.impl.StdSchedulerFactory; |
| | | |
| | | import com.ximple.eofms.jobs.OracleConvertDgn2ShpJob; |
| | |
| | | /** |
| | | * Hello world! |
| | | */ |
| | | public class XQuartzJobCarrier |
| | | { |
| | | public class XQuartzJobCarrier { |
| | | static Log logger = LogFactory.getLog(XQuartzJobCarrier.class); |
| | | static Options options = new Options(); |
| | | |
| | | private static final String VERSION = "0.9.0"; |
| | | private static final String VERSION = "1.3.1"; |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | public static void main(String[] args) { |
| | | XQuartzJobCarrier instance = new XQuartzJobCarrier(); |
| | | instance.initializeOption(); |
| | | instance.execute(args); |
| | | } |
| | | |
| | | private void initializeOption() |
| | | { |
| | | private void initializeOption() { |
| | | Option option; |
| | | option = OptionBuilder.create("help"); |
| | | option.setDescription("print this message"); |
| | |
| | | |
| | | } |
| | | |
| | | private void execute(String[] args) |
| | | { |
| | | private void execute(String[] args) { |
| | | // CommandLineParser parser = new GnuParser(); |
| | | CommandLineParser parser = new PosixParser(); |
| | | CommandLine commandLine = null; |
| | | try |
| | | { |
| | | try { |
| | | // parse the command commandLine arguments |
| | | commandLine = parser.parse(options, args); |
| | | } |
| | | catch (ParseException exp) |
| | | { |
| | | catch (ParseException exp) { |
| | | // oops, something went wrong |
| | | System.err.println("Parsing failed. Reason: " + exp.getMessage()); |
| | | } |
| | | |
| | | if ((commandLine != null) && (commandLine.getOptions().length > 0)) |
| | | { |
| | | if (commandLine.hasOption("help")) |
| | | { |
| | | if ((commandLine != null) && (commandLine.getOptions().length > 0)) { |
| | | if (commandLine.hasOption("help")) { |
| | | printHelpMessage(); |
| | | } else if (commandLine.hasOption("version")) |
| | | { |
| | | } else if (commandLine.hasOption("version")) { |
| | | printVersionMessage(); |
| | | } else if (commandLine.hasOption("wizard")) |
| | | { |
| | | } else if (commandLine.hasOption("wizard")) { |
| | | startWizardMode(); |
| | | } |
| | | return; |
| | |
| | | startScheduler(); |
| | | } |
| | | |
| | | private void printHelpMessage() |
| | | { |
| | | private void printHelpMessage() { |
| | | HelpFormatter formatter = new HelpFormatter(); |
| | | formatter.printHelp("XQuartzJobCarrier", options); |
| | | } |
| | | |
| | | private void printVersionMessage() |
| | | { |
| | | private void printVersionMessage() { |
| | | System.out.println("XQuartzJobCarrier - " + VERSION); |
| | | } |
| | | |
| | | public void startWizardMode() |
| | | { |
| | | Runnable runnable = new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | public void startWizardMode() { |
| | | Runnable runnable = new Runnable() { |
| | | public void run() { |
| | | Wizard wizard = new XQuartzJobWizard((JFrame) null); |
| | | |
| | | wizard.pack(); |
| | | wizard.setVisibleOnCenterOfScreen(); |
| | | } |
| | | }; |
| | | try |
| | | { |
| | | try { |
| | | SwingUtilities.invokeLater(runnable); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void startScheduler() |
| | | { |
| | | public void startScheduler() { |
| | | Scheduler scheduler = null; |
| | | boolean shutdown = false; |
| | | |
| | | try |
| | | { |
| | | try { |
| | | // Get a Scheduler instance from the Factory |
| | | scheduler = StdSchedulerFactory.getDefaultScheduler(); |
| | | |
| | |
| | | scheduler.start(); |
| | | logger.info("Scheduler started at " + new Date()); |
| | | |
| | | } catch (SchedulerException ex) |
| | | { |
| | | } catch (SchedulerException ex) { |
| | | // deal with any exceptions |
| | | logger.error(ex); |
| | | logger.error(ex, ex); |
| | | shutdown = true; |
| | | } catch (Throwable throwable) |
| | | { |
| | | } catch (Throwable throwable) { |
| | | logger.error(throwable.getMessage(), throwable); |
| | | shutdown = true; |
| | | } |
| | | if (shutdown) |
| | | { |
| | | try |
| | | { |
| | | if (shutdown) { |
| | | try { |
| | | scheduler.shutdown(); |
| | | } catch (SchedulerException e) |
| | | { |
| | | } catch (SchedulerException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | } |
| | |
| | | /* |
| | | * return an instance of the Scheduler from the factory |
| | | */ |
| | | public Scheduler createScheduler() throws SchedulerException |
| | | { |
| | | public Scheduler createScheduler() throws SchedulerException { |
| | | return StdSchedulerFactory.getDefaultScheduler(); |
| | | } |
| | | |
| | | // Create and Schedule a ScanDirectoryJob with the Scheduler |
| | | private void scheduleJob(Scheduler scheduler) throws SchedulerException |
| | | { |
| | | private void scheduleJob(Scheduler scheduler) throws SchedulerException { |
| | | |
| | | // Create a JobDetail for the Job |
| | | JobDetail jobDetail = new JobDetail("ScanDirectory", Scheduler.DEFAULT_GROUP, |
| | | /* |
| | | JobDetailImpl jobDetail = new JobDetailImpl("ScanDirectory", Scheduler.DEFAULT_GROUP, |
| | | OracleConvertDgn2ShpJob.class); |
| | | |
| | | */ |
| | | JobDetail jobDetail = JobBuilder.newJob(OracleConvertDgn2ShpJob.class) |
| | | .withIdentity("ScanDirectory", Scheduler.DEFAULT_GROUP) |
| | | .usingJobData("SCAN_DIR", "c:\\quartz-book\\input") |
| | | .build(); |
| | | // Configure the directory to scan |
| | | jobDetail.getJobDataMap().put("SCAN_DIR", "c:\\quartz-book\\input"); |
| | | // jobDetail.getJobDataMap().put("SCAN_DIR", "c:\\quartz-book\\input"); |
| | | |
| | | // Create a trigger that fires every 10 seconds, forever |
| | | Trigger trigger = TriggerUtils.makeSecondlyTrigger(10); |
| | | trigger.setName("scanTrigger"); |
| | | // Trigger trigger = TriggerUtils.makeSecondlyTrigger(10); |
| | | // trigger.setName("scanTrigger"); |
| | | Trigger trigger = TriggerBuilder.newTrigger().withIdentity("scanTrigger") |
| | | .startAt(DateBuilder.futureDate(10, DateBuilder.IntervalUnit.SECOND)) |
| | | .build(); |
| | | // Start the trigger firing from now |
| | | trigger.setStartTime(new Date()); |
| | | // trigger.setStartTime(new Date()); |
| | | |
| | | // Associate the trigger with the job in the scheduler |
| | | scheduler.scheduleJob(jobDetail, trigger); |
| | |
| | | package com.ximple.eofms; |
| | | |
| | | import java.awt.Dimension; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.event.ActionEvent; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.util.ResourceBundle; |
| | | import javax.swing.AbstractAction; |
| | | import javax.swing.Action; |
| | | import javax.swing.BorderFactory; |
| | |
| | | import javax.swing.event.ChangeListener; |
| | | import javax.swing.event.DocumentEvent; |
| | | import javax.swing.event.DocumentListener; |
| | | import java.awt.Dimension; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.event.ActionEvent; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.util.ResourceBundle; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | |
| | | import org.awl.header.EclipseWizardHeader; |
| | | import org.awl.message.MessageLevel; |
| | | |
| | | public class XQuartzJobWizard extends DefaultWizard |
| | | { |
| | | public class XQuartzJobWizard extends DefaultWizard { |
| | | static Log logger = LogFactory.getLog(XQuartzJobWizard.class); |
| | | |
| | | /** |
| | |
| | | /** |
| | | * Creates a new instance of AwlDemo |
| | | */ |
| | | public XQuartzJobWizard(JFrame frame) |
| | | { |
| | | public XQuartzJobWizard(JFrame frame) { |
| | | super(frame); |
| | | |
| | | AbstractWizardHeader header = new EclipseWizardHeader(); |
| | |
| | | secondPage.setMessage(rb.getString("second.messageContent"), MessageLevel.INFO); |
| | | |
| | | URL licenseUrl = null; |
| | | try |
| | | { |
| | | try { |
| | | licenseUrl = new URL("http://www.gnu.org/licenses/lgpl-2.1.txt"); |
| | | } |
| | | catch (MalformedURLException e) |
| | | { |
| | | catch (MalformedURLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | JEditorPane licensePane = null; |
| | | if (licenseUrl == null) |
| | | { |
| | | if (licenseUrl == null) { |
| | | licensePane = new JEditorPane(); |
| | | licensePane.setText("license LGPL 2.1"); |
| | | } else |
| | | { |
| | | try |
| | | { |
| | | } else { |
| | | try { |
| | | licensePane = new JEditorPane(licenseUrl); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | catch (IOException e) { |
| | | licensePane = new JEditorPane(); |
| | | licensePane.setText("license LGPL 2.1"); |
| | | } |
| | |
| | | licenseButtonGroup.add(radioAcceptLicense); |
| | | licenseButtonGroup.add(radioRefuseLicense); |
| | | |
| | | ChangeListener changeListener = new ChangeListener() |
| | | { |
| | | public void stateChanged(ChangeEvent e) |
| | | { |
| | | ChangeListener changeListener = new ChangeListener() { |
| | | public void stateChanged(ChangeEvent e) { |
| | | secondPage.setNextPageAuthorization( |
| | | radioAcceptLicense.isSelected() ? NavigationAuthorization.DEFAULT : |
| | | NavigationAuthorization.FORBIDDEN); |
| | |
| | | |
| | | /** third page */ |
| | | final JTextField locationField = new JTextField(20); |
| | | final Action chooseLocation = new AbstractAction() |
| | | { |
| | | public void actionPerformed(ActionEvent e) |
| | | { |
| | | final Action chooseLocation = new AbstractAction() { |
| | | public void actionPerformed(ActionEvent e) { |
| | | File current = null; |
| | | String text = locationField.getText(); |
| | | if (text != null && text.trim().length() > 0) |
| | | { |
| | | try |
| | | { |
| | | if (text != null && text.trim().length() > 0) { |
| | | try { |
| | | current = new File(text); |
| | | if (!current.exists()) |
| | | { |
| | | if (!current.exists()) { |
| | | current = null; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { } |
| | | catch (Exception ex) { |
| | | } |
| | | } |
| | | |
| | | JFileChooser chooser = new JFileChooser(current); |
| | | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| | | chooser.setFileFilter(new javax.swing.filechooser.FileFilter() |
| | | { |
| | | public boolean accept(File f) |
| | | { |
| | | chooser.setFileFilter(new javax.swing.filechooser.FileFilter() { |
| | | public boolean accept(File f) { |
| | | boolean result = false; |
| | | |
| | | if (f != null && f.isDirectory()) |
| | | { |
| | | if (f != null && f.isDirectory()) { |
| | | result = true; |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public String getDescription() |
| | | { |
| | | public String getDescription() { |
| | | return rb.getString("third.fileChooser.description"); |
| | | } |
| | | }); |
| | | chooser.setMultiSelectionEnabled(false); |
| | | int answer = chooser.showDialog(XQuartzJobWizard.this, rb.getString("third.fileChooser.selectLabel")); |
| | | |
| | | if (answer == JFileChooser.CANCEL_OPTION) |
| | | { |
| | | if (answer == JFileChooser.CANCEL_OPTION) { |
| | | locationField.setText(""); |
| | | thirdPage.setMessage(rb.getString("third.messageContent"), MessageLevel.WARN); |
| | | } else // aprove |
| | |
| | | } |
| | | } |
| | | }; |
| | | this.thirdPage = new DefaultWizardPageDescriptor() |
| | | { |
| | | public void displayingPanel(Wizard wizard) |
| | | { |
| | | this.thirdPage = new DefaultWizardPageDescriptor() { |
| | | public void displayingPanel(Wizard wizard) { |
| | | /** open file dialog box */ |
| | | if (locationField.getText().trim().length() == 0) |
| | | { |
| | | if (locationField.getText().trim().length() == 0) { |
| | | chooseLocation.actionPerformed(null); |
| | | } |
| | | } |
| | |
| | | chooseLocation.putValue(Action.SMALL_ICON, new ImageIcon(AwlDemo.class.getResource("/org/awl/rc/folder.png"))); |
| | | thirdPage.setNextPageAuthorization(NavigationAuthorization.FORBIDDEN); |
| | | |
| | | locationField.getDocument().addDocumentListener(new DocumentListener() |
| | | { |
| | | public void changedUpdate(DocumentEvent e) |
| | | { } |
| | | locationField.getDocument().addDocumentListener(new DocumentListener() { |
| | | public void changedUpdate(DocumentEvent e) { } |
| | | |
| | | public void insertUpdate(DocumentEvent e) |
| | | { |
| | | public void insertUpdate(DocumentEvent e) { |
| | | this.changeNavigation(); |
| | | } |
| | | |
| | | public void removeUpdate(DocumentEvent e) |
| | | { |
| | | public void removeUpdate(DocumentEvent e) { |
| | | this.changeNavigation(); |
| | | } |
| | | |
| | | private void changeNavigation() |
| | | { |
| | | private void changeNavigation() { |
| | | thirdPage.setNextPageAuthorization(locationField.getText().trim().length() > 0 ? NavigationAuthorization.DEFAULT : |
| | | NavigationAuthorization.FORBIDDEN); |
| | | } |
| | |
| | | final JProgressBar installProgressBar = new JProgressBar(); |
| | | final JLabel progressLabel = new JLabel(rb.getString("fourth.inProgress.text")); |
| | | |
| | | this.fourthPage = new DefaultWizardPageDescriptor() |
| | | { |
| | | public void displayingPanel(Wizard wizard) |
| | | { |
| | | this.fourthPage = new DefaultWizardPageDescriptor() { |
| | | public void displayingPanel(Wizard wizard) { |
| | | /* begin installation */ |
| | | this.setPreviousPageAuthorization(NavigationAuthorization.FORBIDDEN); |
| | | this.setFinishAuthorization(NavigationAuthorization.FORBIDDEN); |
| | | |
| | | /* begin new thread */ |
| | | Runnable runnable = new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | while (installProgressBar.getValue() < installProgressBar.getMaximum()) |
| | | { |
| | | Runnable r = new Runnable() |
| | | { |
| | | public void run() |
| | | { installProgressBar.setValue(installProgressBar.getValue() + 1); } |
| | | Runnable runnable = new Runnable() { |
| | | public void run() { |
| | | while (installProgressBar.getValue() < installProgressBar.getMaximum()) { |
| | | Runnable r = new Runnable() { |
| | | public void run() { installProgressBar.setValue(installProgressBar.getValue() + 1); } |
| | | }; |
| | | SwingUtilities.invokeLater(r); |
| | | |
| | | try |
| | | { |
| | | try { |
| | | Thread.sleep(50); |
| | | } |
| | | catch (InterruptedException e) |
| | | { |
| | | Runnable r1 = new Runnable() |
| | | { |
| | | public void run() |
| | | { installProgressBar.setValue(installProgressBar.getMaximum()); } |
| | | catch (InterruptedException e) { |
| | | Runnable r1 = new Runnable() { |
| | | public void run() { installProgressBar.setValue(installProgressBar.getMaximum()); } |
| | | }; |
| | | SwingUtilities.invokeLater(r1); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | Runnable r2 = new Runnable() |
| | | { |
| | | public void run() |
| | | { progressLabel.setText(rb.getString("fourth.finished.text")); } |
| | | Runnable r2 = new Runnable() { |
| | | public void run() { progressLabel.setText(rb.getString("fourth.finished.text")); } |
| | | }; |
| | | SwingUtilities.invokeLater(r2); |
| | | |
| | |
| | | this.addPage(fourthPage, "4"); |
| | | } |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | Runnable runnable = new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | public static void main(String[] args) { |
| | | Runnable runnable = new Runnable() { |
| | | public void run() { |
| | | Wizard wizard = new XQuartzJobWizard((JFrame) null); |
| | | |
| | | wizard.pack(); |
| | |
| | | } |
| | | }; |
| | | |
| | | try |
| | | { |
| | | try { |
| | | SwingUtilities.invokeLater(runnable); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | title=Ximple Quartz Job Wizard |
| | | |
| | | first.title=ªÅ¶¡¸ê®ÆÂà´« |
| | | first.description=ªÅ¶¡¸ê®ÆÂà´«±N·|Ū¨ú OMS/CMMS ªÅ¶¡¸ê®Æ®w¤º®eÂà´«¦Ü PostGIS ªÅ¶¡¸ê®Æ®w |
| | | first.title=空間資料轉換 |
| | | first.description=空間資料轉換將會讀取 OMS/CMMS 空間資料庫內容轉換至 PostGIS 空間資料庫 |
| | | first.label.text=<html>This wizard will not install anything on your computer.<br/>It only demonstrates <b>Awl</b> functionnalities.</html> |
| | | |
| | | second.title=ª©ÅvÁn©ú |
| | | second.title=版權聲明 |
| | | second.description=Accept the license of this software |
| | | second.licenseAccepted=I accept the terms of this license agreement |
| | | second.licenseRefused=I do not accept the terms of this license agreement |
| | | second.messageContent=Accept the terms of the license |
| | | |
| | | third.title=²ÕºA³]©w¦ì¸m |
| | | third.title=組態設定位置 |
| | | third.description=Select the location where to install this software |
| | | third.label.text=Install location |
| | | third.fileChooser.selectLabel=Select |
| | | third.fileChooser.description=Select |
| | | third.messageContent=You must choose a valid location |
| | | |
| | | fourth.title=¶}©lÂàÀÉ... |
| | | fourth.title=開始轉檔... |
| | | fourth.description=Installation progress |
| | | fourth.inProgress.text=Installation in progress... |
| | | fourth.finished.text=Installation finished |
| | |
| | | # Print messages of level INFO or above for examples |
| | | log4j.logger.org.cavaness.quartzbook=INFO |
| | | log4j.logger.com.ximple.eofms=INFO |
| | | |
| | | it.geosolutions.geoserver=INIFO |
| | |
| | | #Configure JobStore |
| | | #=============================================================== |
| | | org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore |
| | | org.quartz.jobStore.misfireThreshold = 60000 |
| | | |
| | | #=============================================================== |
| | | #Configure Plugins |
| | | #=============================================================== |
| | | org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.JobInitializationPlugin |
| | | org.quartz.plugin.triggHistory.class = org.quartz.plugins.history.LoggingJobHistoryPlugin |
| | | |
| | | org.quartz.plugin.jobInitializer.fileName = quartz_jobs.xml |
| | | org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin |
| | | org.quartz.plugin.jobInitializer.fileNames = quartz_jobs.xml |
| | | #org.quartz.plugin.jobInitializer.fileNames = quartz_jobs_edb.xml |
| | | |
| | | org.quartz.plugin.jobInitializer.overWriteExistingJobs = true |
| | | org.quartz.plugin.jobInitializer.failOnFileNotFound = true |
| | | org.quartz.plugin.jobInitializer.validating=false |
| | | org.quartz.plugin.jobInitializer.scanInterval = 10 |
| | | org.quartz.plugin.jobInitializer.wrapInUserTransaction = false |
| | | |
| | | org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin |
| | | org.quartz.plugin.shutdownhook.cleanShutdown = true |
| | |
| | | <?xml version='1.0' encoding='utf-8'?> |
| | | |
| | | <quartz xmlns="http://www.opensymphony.com/quartz/JobSchedulingData" |
| | | <job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://www.opensymphony.com/quartz/JobSchedulingData |
| | | http://www.opensymphony.com/quartz/xml/job_scheduling_data_1_5.xsd" |
| | | version="1.5"> |
| | | xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd" |
| | | version="1.8"> |
| | | |
| | | <pre-processing-commands> |
| | | <delete-jobs-in-group>*</delete-jobs-in-group> |
| | | <!-- clear all jobs in scheduler --> |
| | | <delete-triggers-in-group>*</delete-triggers-in-group> |
| | | <!-- clear all triggers in scheduler --> |
| | | </pre-processing-commands> |
| | | |
| | | <processing-directives> |
| | | <!-- if there are any jobs/trigger in scheduler of same name (as in this file), overwrite them --> |
| | | <overwrite-existing-data>true</overwrite-existing-data> |
| | | <!-- if there are any jobs/trigger in scheduler of same name (as in this file), and over-write is false, ignore them rather then generating an error --> |
| | | <ignore-duplicates>false</ignore-duplicates> |
| | | </processing-directives> |
| | | |
| | | <schedule> |
| | | <job> |
| | | <job-detail> |
| | | <name>ConvertDgn2PostGisIntoPostgre</name> |
| | | <name>ConvertDMMS2PostGisWithGeoserver</name> |
| | | <group>DEFAULT</group> |
| | | <description>A job that convert dgn to shapefiles</description> |
| | | <job-class>com.ximple.eofms.jobs.OracleConvertDgn2PostGISJob</job-class> |
| | | <volatility>false</volatility> |
| | | <description>A job that convert dgn to postgis</description> |
| | | <!--job-class>com.ximple.eofms.jobs.OracleConvertDgn2PostGISJob</job-class--> |
| | | <job-class>com.ximple.eofms.jobs.GeoserverIntegrateConfigJob</job-class> |
| | | <!--job-class>com.ximple.eofms.jobs.OracleTransformColorOwnerJob</job-class--> |
| | | <!--job-class>com.ximple.eofms.jobs.OracleTransformColorOwner2CSVJob</job-class--> |
| | | <!--volatility>false</volatility--> |
| | | <durability>false</durability> |
| | | <recover>false</recover> |
| | | <job-data-map allows-transient-data="true"> |
| | | <!--job-data-map allows-transient-data="true"--> |
| | | <job-data-map> |
| | | <entry> |
| | | <key>JOBDATA_DIR</key> |
| | | <value>G:\Temp\JobData\tctpc</value> |
| | | <value>/Users/Shared/Public/Projects/XGeoDMMS/xjobrun/tctpcjobs/jobdata</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGHOST</key> |
| | | <value>192.168.11.200</value> |
| | | <value>10.10.1.17</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGDDATBASE</key> |
| | | <value>tctpc</value> |
| | | <key>PGDATBASE</key> |
| | | <value>pgDMMS</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGPORT</key> |
| | |
| | | </entry> |
| | | <entry> |
| | | <key>PGUSER</key> |
| | | <value>spatialdb</value> |
| | | <value>tpcdb</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PGPASS</key> |
| | | <value>spatialdb000</value> |
| | | <value>simple000</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORAHOST</key> |
| | | <value>192.168.11.200</value> |
| | | <value>10.10.1.17</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORAINST</key> |
| | | <value>tctpc</value> |
| | | <value>orcl</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORAPORT</key> |
| | |
| | | </entry> |
| | | <entry> |
| | | <key>ORAUSER</key> |
| | | <value>spatialdb</value> |
| | | <value>system</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORAPASS</key> |
| | | <value>spatialdb000</value> |
| | | <value>simple000</value> |
| | | </entry> |
| | | <entry> |
| | | <key>ORGSCHEMA</key> |
| | | <!--value>SPATIALDB</value--> |
| | | <value>SPATIALDB, CMMS_SPATIALDB</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CONVERTDB</key> |
| | | <value>true</value> |
| | | <value>false</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CONVERTFILE</key> |
| | | <value>true</value> |
| | | <value>false</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CONVERTELEMIN</key> |
| | | <value>false</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CONVERTPWTHEMES</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>CREATEDUMMY</key> |
| | |
| | | <key>COPYCONNECTIVITYMODE</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>PROFILEMODE</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>USEZONE121</key> |
| | | <value>true</value> |
| | | </entry> |
| | | <entry> |
| | | <key>GEOSERVER_URL</key> |
| | | <value>http://10.10.1.17:8080/geoserver</value> |
| | | </entry> |
| | | <entry> |
| | | <key>GEOSERVER_USER</key> |
| | | <value>admin</value> |
| | | </entry> |
| | | <entry> |
| | | <key>GEOSERVER_PASS</key> |
| | | <value>geoserver</value> |
| | | </entry> |
| | | <entry> |
| | | <key>IGNORE_DBETL</key> |
| | | <value>false</value> |
| | | </entry> |
| | | </job-data-map> |
| | | </job-detail> |
| | | </job> |
| | | |
| | | <trigger> |
| | | <simple> |
| | | <name>convertTrigger</name> |
| | | <group>DEFAULT</group> |
| | | <job-name>ConvertDgn2PostGisIntoPostgre</job-name> |
| | | <job-name>ConvertDMMS2PostGisWithGeoserver</job-name> |
| | | <job-group>DEFAULT</job-group> |
| | | <start-time>2008-03-01T18:10:00</start-time> |
| | | <start-time>2013-03-01T18:00:00</start-time> |
| | | <!-- repeat indefinitely every 10 seconds --> |
| | | <repeat-count>0</repeat-count> |
| | | <repeat-interval>500</repeat-interval> |
| | |
| | | </simple> |
| | | </trigger> |
| | | |
| | | </job> |
| | | </quartz> |
| | | </schedule> |
| | | |
| | | </job-scheduling-data> |
New file |
| | |
| | | <?xml version='1.0' encoding='utf-8'?>
|
| | |
|
| | | <job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
|
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| | | xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
|
| | | version="1.8">
|
| | |
|
| | | <pre-processing-commands>
|
| | | <delete-jobs-in-group>*</delete-jobs-in-group>
|
| | | <!-- clear all jobs in scheduler -->
|
| | | <delete-triggers-in-group>*</delete-triggers-in-group>
|
| | | <!-- clear all triggers in scheduler -->
|
| | | </pre-processing-commands>
|
| | |
|
| | | <processing-directives>
|
| | | <!-- if there are any jobs/trigger in scheduler of same name (as in this file), overwrite them -->
|
| | | <overwrite-existing-data>true</overwrite-existing-data>
|
| | | <!-- if there are any jobs/trigger in scheduler of same name (as in this file), and over-write is false, ignore them rather then generating an error -->
|
| | | <ignore-duplicates>false</ignore-duplicates>
|
| | | </processing-directives>
|
| | |
|
| | | <schedule>
|
| | | <job>
|
| | | <name>ConvertDgn2GeoSpatialIntoEdb</name>
|
| | | <group>DEFAULT</group>
|
| | | <description>A job that convert dgn to gdb spatial</description>
|
| | | <!--job-class>com.ximple.eofms.jobs.OracleConvertDgn2EdbGeoJob</job-class-->
|
| | | <job-class>com.ximple.eofms.jobs.OracleConvertDgn2EdbGeoJob</job-class>
|
| | | <volatility>false</volatility>
|
| | | <durability>false</durability>
|
| | | <recover>false</recover>
|
| | | <!--job-data-map allows-transient-data="true"-->
|
| | | <job-data-map>
|
| | | <entry>
|
| | | <key>JOBDATA_DIR</key>
|
| | | <value>C:\Usr\Projects\XDCAD\nstpcjobs\jobdata</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>EDBHOST</key>
|
| | | <value>192.168.11.99</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>EDBDATBASE</key>
|
| | | <value>tpcdb</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>EDBPORT</key>
|
| | | <value>5444</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>EDBSCHEMA</key>
|
| | | <value>public</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>EDBUSER</key>
|
| | | <value>tpcdb</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>EDBPASS</key>
|
| | | <value>simple000</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>ORAHOST</key>
|
| | | <value>192.168.11.200</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>ORAINST</key>
|
| | | <value>nntpc</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>ORAPORT</key>
|
| | | <value>1521</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>ORAUSER</key>
|
| | | <value>spatialdb</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>ORAPASS</key>
|
| | | <value>spatialdb000</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>ORGSCHEMA</key>
|
| | | <value>SPATIALDB, CMMS_SPATIALDB</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>CONVERTDB</key>
|
| | | <value>true</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>CONVERTFILE</key>
|
| | | <value>false</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>CONVERTELEMIN</key>
|
| | | <value>false</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>CREATEDUMMY</key>
|
| | | <value>false</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>ELEMLOG</key>
|
| | | <value>true</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>USEWKB</key>
|
| | | <value>true</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>TESTMODE</key>
|
| | | <value>false</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>TESTCOUNT</key>
|
| | | <value>2</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>COPYCONNECTIVITYMODE</key>
|
| | | <value>false</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>PROFILEMODE</key>
|
| | | <value>true</value>
|
| | | </entry>
|
| | | <entry>
|
| | | <key>USEZONE121</key>
|
| | | <value>true</value>
|
| | | </entry>
|
| | | </job-data-map>
|
| | | </job>
|
| | |
|
| | | <trigger>
|
| | | <simple>
|
| | | <name>convertTrigger</name>
|
| | | <group>DEFAULT</group>
|
| | | <job-name>ConvertDgn2GeoSpatialIntoEdb</job-name>
|
| | | <job-group>DEFAULT</job-group>
|
| | | <start-time>2008-03-01T18:10:00</start-time>
|
| | | <!-- repeat indefinitely every 10 seconds -->
|
| | | <repeat-count>0</repeat-count>
|
| | | <repeat-interval>500</repeat-interval>
|
| | | <!-- <repeat-interval>72000000</repeat-interval> -->
|
| | | </simple>
|
| | | </trigger>
|
| | |
|
| | | </schedule>
|
| | | </job-scheduling-data>
|
| | |
| | | /** |
| | | * Unit test for simple App. |
| | | */ |
| | | public class XQuartzJobCarrierTest |
| | | { |
| | | public class XQuartzJobCarrierTest { |
| | | /** |
| | | * Rigourous Test :-) |
| | | */ |
| | | @Test |
| | | public void testApp() |
| | | { |
| | | public void testApp() { |
| | | Assert.assertTrue(true); |
| | | } |
| | | } |
| | |
| | | <parent> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-dgnjobs</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | </parent> |
| | | |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>ximple-spatialjob</artifactId> |
| | | <version>0.9.0</version> |
| | | <version>2.1.1</version> |
| | | <packaging>jar</packaging> |
| | | <name>ximple-spatialjob</name> |
| | | <url>http://www.ximple.com.tw</url> |
| | | |
| | | <properties> |
| | | <xdgnio.version>0.9.0</xdgnio.version> |
| | | <xdgnio.version>2.1.1</xdgnio.version> |
| | | </properties> |
| | | |
| | | <description> |
| | |
| | | <url>http://www.ximple.com.tw</url> |
| | | </organization> |
| | | |
| | | <inceptionYear>2008</inceptionYear> |
| | | <inceptionYear>2010</inceptionYear> |
| | | |
| | | <developers> |
| | | <developer> |
| | |
| | | <!-- =========================================================== --> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.quartz-scheduler</groupId> |
| | | <artifactId>quartz</artifactId> |
| | | <groupId>opensymphony</groupId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.quartz-scheduler</groupId> |
| | | <artifactId>quartz-jobs</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-api</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-log4j12</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>jcl-over-slf4j</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-shapefile</artifactId> |
| | | <artifactId>gt-shapefile</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-sample-data</artifactId> |
| | | <artifactId>gt-sample-data</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-data</artifactId> |
| | | <artifactId>gt-data</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-jdbc</artifactId> |
| | | <artifactId>gt-jdbc</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-postgis</artifactId> |
| | | <groupId>org.geotools.jdbc</groupId> |
| | | <artifactId>gt-jdbc-postgis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-oracle-spatial</artifactId> |
| | | <groupId>org.geotools.jdbc</groupId> |
| | | <artifactId>gt-jdbc-oracle</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-mysql</artifactId> |
| | | <groupId>org.geotools.jdbc</groupId> |
| | | <artifactId>gt-jdbc-mysql</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- because main and sample-data depend on referencing we need a tie breaker --> |
| | | <dependency> |
| | | <groupId>org.geotools</groupId> |
| | | <artifactId>gt2-referencing</artifactId> |
| | | <artifactId>gt-referencing</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- We need this to make the referencing module useful --> |
| | | <dependency> |
| | | <artifactId>gt2-epsg-hsql</artifactId> |
| | | <groupId>org.geotools</groupId> |
| | | <scope>test</scope> |
| | | <artifactId>gt-epsg-wkt</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <artifactId>jdom</artifactId> |
| | | <groupId>jdom</groupId> |
| | | <groupId>org.jdom</groupId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | |
| | | <artifactId>sdoutl</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <!--dependency> |
| | | <groupId>postgresql</groupId> |
| | | <artifactId>postgresql</artifactId> |
| | | </dependency> |
| | | </dependency--> |
| | | <dependency> |
| | | <groupId>org.postgis</groupId> |
| | | <artifactId>postgis-driver</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.ximple.eofms</groupId> |
| | | <artifactId>xedb-gt-geospatial</artifactId> |
| | | </dependency> |
| | | |
| | | <!--dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | </dependency--> |
| | | |
| | | <dependency> |
| | | <groupId>net.sf.opencsv</groupId> |
| | | <artifactId>opencsv</artifactId> |
| | | <version>2.3</version> |
| | | </dependency> |
| | | |
| | | <!-- Ximple Library --> |
| | |
| | | |
| | | import java.util.TreeMap; |
| | | |
| | | public class FeatureClassification |
| | | { |
| | | public class FeatureClassification { |
| | | private TreeMap<String, FeatureTypeCollector> clasificationRules; |
| | | |
| | | public FeatureClassification() |
| | | { |
| | | public FeatureClassification() { |
| | | clasificationRules = new TreeMap<String, FeatureTypeCollector>(); |
| | | } |
| | | |
| | | public void addCollector(FeatureTypeCollector collector) |
| | | { |
| | | public void addCollector(FeatureTypeCollector collector) { |
| | | collector.getName(); |
| | | } |
| | | |
| | | public boolean containsKey(String typeName) |
| | | { |
| | | public boolean containsKey(String typeName) { |
| | | return clasificationRules.containsKey(typeName); |
| | | } |
| | | |
| | | public TreeMap<String, FeatureTypeCollector> getClasificationRules() |
| | | { |
| | | public TreeMap<String, FeatureTypeCollector> getClasificationRules() { |
| | | return clasificationRules; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.ximple.eofms.util.StringUtils; |
| | | |
| | | public class FeatureTypeCollector |
| | | { |
| | | public class FeatureTypeCollector { |
| | | private String name; |
| | | private String description; |
| | | private String featuretypeList; |
| | | private ArrayList<String> featureTypeNameList; |
| | | |
| | | public FeatureTypeCollector() |
| | | { |
| | | public FeatureTypeCollector() { |
| | | } |
| | | |
| | | public String getName() |
| | | { |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) |
| | | { |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getDescription() |
| | | { |
| | | public String getDescription() { |
| | | return description; |
| | | } |
| | | |
| | | public void setDescription(String description) |
| | | { |
| | | public void setDescription(String description) { |
| | | this.description = description; |
| | | } |
| | | |
| | | public String getFeaturetypeList() |
| | | { |
| | | public String getFeaturetypeList() { |
| | | return featuretypeList; |
| | | } |
| | | |
| | | public void setFeaturetypeList(String featuretypeList) |
| | | { |
| | | public void setFeaturetypeList(String featuretypeList) { |
| | | featureTypeNameList = StringUtils.split(featuretypeList, ","); |
| | | this.featuretypeList = featuretypeList; |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.LinkedList; |
| | | |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import com.ximple.io.dgn7.Element; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | |
| | | import com.ximple.io.dgn7.Element; |
| | | import javax.swing.event.EventListenerList; |
| | | import java.util.LinkedList; |
| | | |
| | | public abstract class AbstractDispatchableFilter implements ElementDispatchableFilter |
| | | { |
| | | public abstract class AbstractDispatchableFilter implements ElementDispatchableFilter { |
| | | private String name; |
| | | private String description; |
| | | private LinkedList<ElementTypeCriterion> typeIdCriterions; |
| | | private LinkedList<ElementLevelCriterion> levelCriterions; |
| | | |
| | | protected Log logger = LogFactory.getLog(AbstractFLinkageDispatchableFilter.class); |
| | | protected static final Log logger = LogFactory.getLog(AbstractDispatchableFilter.class); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public AbstractDispatchableFilter() |
| | | { |
| | | public AbstractDispatchableFilter() { |
| | | typeIdCriterions = new LinkedList<ElementTypeCriterion>(); |
| | | levelCriterions = new LinkedList<ElementLevelCriterion>(); |
| | | } |
| | | |
| | | public String getName() |
| | | { |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) |
| | | { |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getDescription() |
| | | { |
| | | public String getDescription() { |
| | | return description; |
| | | } |
| | | |
| | | public void setDescription(String description) |
| | | { |
| | | public void setDescription(String description) { |
| | | this.description = description; |
| | | } |
| | | |
| | | public void addCriterion(ElementTypeCriterion criterion) |
| | | { |
| | | public void addCriterion(ElementTypeCriterion criterion) { |
| | | typeIdCriterions.add(criterion); |
| | | } |
| | | |
| | | public void addLevelCriterion(ElementLevelCriterion criterion) |
| | | { |
| | | public void addLevelCriterion(ElementLevelCriterion criterion) { |
| | | levelCriterions.add(criterion); |
| | | } |
| | | |
| | | protected int compareType(Element element) |
| | | { |
| | | for (ElementTypeCriterion criterion : typeIdCriterions) |
| | | { |
| | | protected int compareType(Element element) { |
| | | for (ElementTypeCriterion criterion : typeIdCriterions) { |
| | | if (criterion.compareTo(element) == 0) |
| | | return 0; |
| | | } |
| | | return -1; |
| | | } |
| | | |
| | | protected int compareLevel(Element element) |
| | | { |
| | | for (ElementLevelCriterion criterion : levelCriterions) |
| | | { |
| | | protected int compareLevel(Element element) { |
| | | for (ElementLevelCriterion criterion : levelCriterions) { |
| | | if (criterion.compareTo(element) == 0) |
| | | return 0; |
| | | } |
| | | return -1; |
| | | } |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | |
| | | public abstract class AbstractFLinkageDispatchableFilter extends AbstractDispatchableFilter |
| | | { |
| | | public static FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | import java.util.List; |
| | | |
| | | public abstract class AbstractFLinkageDispatchableFilter extends AbstractDispatchableFilter { |
| | | public static FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | try { |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | |
| | | if(usrDatas == null) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | } catch (ArrayIndexOutOfBoundsException e) { |
| | | logger.debug(e.getMessage(), e); |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import com.ximple.eofms.util.TWD97GeometryConverterDecorator; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.ArcElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.simple.SimpleFeatureBuilder; |
| | | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | public class CreateArcLineStringStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | import javax.swing.event.EventListenerList; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | public class CreateArcLineStringStrategy implements CreateFeatureTypeStrategy { |
| | | static final Log logger = LogFactory.getLog(CreateLineStringStrategy.class); |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); |
| | | TreeMap<String, SimpleFeatureType> typeBuilders = new TreeMap<String, SimpleFeatureType>(); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public CreateArcLineStringStrategy() |
| | | { |
| | | public CreateArcLineStringStrategy() { |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createArcFeatureTypeBuilder(featureName); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException { |
| | | if (!typeBuilders.containsKey(featureName)) { |
| | | SimpleFeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createArcFeatureTypeBuilder(featureName); |
| | | SimpleFeatureType featureType = typeBuilder.buildFeatureType(); |
| | | typeBuilders.put(featureName, featureType); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, featureType)); |
| | | |
| | | } |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | return typeBuilders.get(featureName); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException |
| | | { |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | FrammeAttributeData fLinkage = getFeatureLinkage(element); |
| | | Feature feature = null; |
| | | SimpleFeature feature = null; |
| | | if (fLinkage == null) return null; |
| | | if (element instanceof ArcElement) |
| | | { |
| | | if (element instanceof ArcElement) { |
| | | ArcElement lineStringElement = (ArcElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(lineStringElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else { |
| | | gobj = lineStringElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(lineStringElement.getColorIndex()), |
| | | (short) lineStringElement.getWeight(), |
| | | (short) lineStringElement.getLineStyle() |
| | | }); |
| | | }, null); |
| | | } |
| | | return feature; |
| | | } |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.LineString; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.*; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.simple.SimpleFeatureBuilder; |
| | | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import com.ximple.eofms.util.TWD97GeometryConverterDecorator; |
| | | import com.ximple.io.dgn7.ArcElement; |
| | | import com.ximple.io.dgn7.ComplexChainElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.LineElement; |
| | | import com.ximple.io.dgn7.LineStringElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import javax.swing.event.EventListenerList; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | public class CreateComplexChainStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | public class CreateComplexChainStrategy implements CreateFeatureTypeStrategy { |
| | | static final Log logger = LogFactory.getLog(CreateLineStringStrategy.class); |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); |
| | | TreeMap<String, SimpleFeatureType> typeBuilders = new TreeMap<String, SimpleFeatureType>(); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public CreateComplexChainStrategy() |
| | | { |
| | | public CreateComplexChainStrategy() { |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createMultiLineFeatureTypeBuilder(featureName); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, typeBuilder.getFeatureType())); |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException { |
| | | if (!typeBuilders.containsKey(featureName)) { |
| | | SimpleFeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createMultiLineFeatureTypeBuilder(featureName); |
| | | SimpleFeatureType featureType = typeBuilder.buildFeatureType(); |
| | | typeBuilders.put(featureName, featureType); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, featureType)); |
| | | } |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | return typeBuilders.get(featureName); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException |
| | | { |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | FrammeAttributeData fLinkage = getFeatureLinkage(element); |
| | | Feature feature = null; |
| | | SimpleFeature feature = null; |
| | | if (fLinkage == null) return null; |
| | | if (element instanceof LineStringElement) |
| | | { |
| | | if (element instanceof LineStringElement) { |
| | | LineStringElement lineStringElement = (LineStringElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | if (useTransform) { |
| | | convertDecorator.setConverter(lineStringElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = lineStringElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj instanceof LineString) |
| | | { |
| | | if (gobj instanceof LineString) { |
| | | gobj = geometryFactory.createMultiLineString(new LineString[]{(LineString) gobj}); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(lineStringElement.getColorIndex()), |
| | | (short) lineStringElement.getWeight(), |
| | | (short) lineStringElement.getLineStyle() |
| | | }); |
| | | } else if (element instanceof ComplexChainElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof ComplexChainElement) { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(complexChain); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | gobj = complexChain.toGeometry(geometryFactory); |
| | | if (gobj instanceof LineString) |
| | | { |
| | | if (gobj instanceof LineString) { |
| | | gobj = geometryFactory.createMultiLineString(new LineString[]{(LineString) gobj}); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(complexChain.getColorIndex()), |
| | | (short) complexChain.getWeight(), |
| | | (short) complexChain.getLineStyle() |
| | | }); |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof LineElement) { |
| | | LineElement lineElement = (LineElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(lineElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = lineElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj instanceof LineString) |
| | | { |
| | | if (gobj instanceof LineString) { |
| | | gobj = geometryFactory.createMultiLineString(new LineString[]{(LineString) gobj}); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(lineElement.getColorIndex()), |
| | | (short) lineElement.getWeight(), |
| | | (short) lineElement.getLineStyle() |
| | | }); |
| | | }, null); |
| | | return feature; |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | } else if (element instanceof ArcElement) { |
| | | ArcElement arcElement = (ArcElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(arcElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = arcElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj instanceof LineString) |
| | | { |
| | | if (gobj instanceof LineString) { |
| | | gobj = geometryFactory.createMultiLineString(new LineString[]{(LineString) gobj}); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(arcElement.getColorIndex()), |
| | | (short) arcElement.getWeight(), |
| | | (short) arcElement.getLineStyle() |
| | | }); |
| | | }, null); |
| | | } |
| | | |
| | | return feature; |
| | | } |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import com.ximple.eofms.util.TWD97GeometryConverterDecorator; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.EllipseElement; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.simple.SimpleFeatureBuilder; |
| | | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | public class CreateEllipseShapeStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | import javax.swing.event.EventListenerList; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | public class CreateEllipseShapeStrategy implements CreateFeatureTypeStrategy { |
| | | static final Log logger = LogFactory.getLog(CreateShapeStrategy.class); |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); |
| | | TreeMap<String, SimpleFeatureType> typeBuilders = new TreeMap<String, SimpleFeatureType>(); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public CreateEllipseShapeStrategy() |
| | | { |
| | | public CreateEllipseShapeStrategy() { |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createEllipseFeatureTypeBuilder(featureName); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException { |
| | | if (!typeBuilders.containsKey(featureName)) { |
| | | SimpleFeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createEllipseFeatureTypeBuilder(featureName); |
| | | SimpleFeatureType featureType = typeBuilder.buildFeatureType(); |
| | | typeBuilders.put(featureName, featureType); |
| | | } |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | return typeBuilders.get(featureName); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException |
| | | { |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | FrammeAttributeData fLinkage = getFeatureLinkage(element); |
| | | Feature feature = null; |
| | | SimpleFeature feature = null; |
| | | if (fLinkage == null) return null; |
| | | if (element instanceof EllipseElement) |
| | | { |
| | | if (element instanceof EllipseElement) { |
| | | EllipseElement ellipseElement = (EllipseElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(ellipseElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = ellipseElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(ellipseElement.getColorIndex()), |
| | | (short) ellipseElement.getWeight(), |
| | | (short) ellipseElement.getLineStyle() |
| | | }); |
| | | }, null); |
| | | } |
| | | return feature; |
| | | } |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | |
| | | |
| | | import java.util.EventListener; |
| | | |
| | | public interface CreateFeatureTypeEventListener extends EventListener |
| | | { |
| | | public interface CreateFeatureTypeEventListener extends EventListener { |
| | | public void createFeatureTypeOccurred(FeatureTypeEvent evt); |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.ximple.io.dgn7.Element; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | public interface CreateFeatureTypeStrategy |
| | | { |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException; |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException; |
| | | public interface CreateFeatureTypeStrategy { |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException; |
| | | |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException; |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener); |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener); |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.MultiLineString; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.*; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.simple.SimpleFeatureBuilder; |
| | | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import com.ximple.eofms.util.TWD97GeometryConverterDecorator; |
| | | import com.ximple.io.dgn7.ArcElement; |
| | | import com.ximple.io.dgn7.ComplexChainElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.LineElement; |
| | | import com.ximple.io.dgn7.LineStringElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import javax.swing.event.EventListenerList; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | public class CreateLineStringStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | public class CreateLineStringStrategy implements CreateFeatureTypeStrategy { |
| | | static final Log logger = LogFactory.getLog(CreateLineStringStrategy.class); |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); |
| | | TreeMap<String, SimpleFeatureType> typeBuilders = new TreeMap<String, SimpleFeatureType>(); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public CreateLineStringStrategy() |
| | | { |
| | | public CreateLineStringStrategy() { |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createLineFeatureTypeBuilder(featureName); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, typeBuilder.getFeatureType())); |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException { |
| | | if (!typeBuilders.containsKey(featureName)) { |
| | | SimpleFeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createLineFeatureTypeBuilder(featureName); |
| | | SimpleFeatureType featureType = typeBuilder.buildFeatureType(); |
| | | typeBuilders.put(featureName, featureType); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, featureType)); |
| | | } |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | return typeBuilders.get(featureName); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException |
| | | { |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | FrammeAttributeData fLinkage = getFeatureLinkage(element); |
| | | Feature feature = null; |
| | | SimpleFeature feature = null; |
| | | if (fLinkage == null) return null; |
| | | if (element instanceof LineStringElement) |
| | | { |
| | | if (element instanceof LineStringElement) { |
| | | LineStringElement lineStringElement = (LineStringElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(lineStringElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = lineStringElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | convertDecorator.toGeometry(geometryFactory), |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(lineStringElement.getColorIndex()), |
| | | (short) lineStringElement.getWeight(), |
| | | (short) lineStringElement.getLineStyle() |
| | | }); |
| | | } else if (element instanceof ComplexChainElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof ComplexChainElement) { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(complexChain); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = complexChain.toGeometry(geometryFactory); |
| | | } |
| | | if ((gobj != null) && (gobj instanceof MultiLineString)) |
| | | { |
| | | if ((gobj != null) && (gobj instanceof MultiLineString)) { |
| | | MultiLineString mline = (MultiLineString) gobj; |
| | | CoordinateList coordinateList = new CoordinateList(); |
| | | for (int i = 0; i < mline.getNumGeometries(); i++) |
| | | { |
| | | for (int i = 0; i < mline.getNumGeometries(); i++) { |
| | | coordinateList.add(mline.getGeometryN(i).getCoordinates(), true); |
| | | } |
| | | |
| | | gobj = geometryFactory.createLineString(coordinateList.toCoordinateArray()); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(complexChain.getColorIndex()), |
| | | (short) complexChain.getWeight(), |
| | | (short) complexChain.getLineStyle() |
| | | }); |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof LineElement) { |
| | | LineElement lineElement = (LineElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(lineElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = lineElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(lineElement.getColorIndex()), |
| | | (short) lineElement.getWeight(), |
| | | (short) lineElement.getLineStyle() |
| | | }); |
| | | }, null); |
| | | return feature; |
| | | } else if (element instanceof ArcElement) |
| | | { |
| | | } else if (element instanceof ArcElement) { |
| | | ArcElement arcElement = (ArcElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(arcElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = arcElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(arcElement.getColorIndex()), |
| | | (short) arcElement.getWeight(), |
| | | (short) arcElement.getLineStyle() |
| | | }); |
| | | }, null); |
| | | } |
| | | |
| | | return feature; |
| | | } |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import com.vividsolutions.jts.geom.*; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.*; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.simple.SimpleFeatureBuilder; |
| | | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | import javax.swing.event.EventListenerList; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.LineString; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.MultiLineString; |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import com.ximple.eofms.util.TWD97GeometryConverterDecorator; |
| | | import com.ximple.eofms.util.TWDDatumConverter; |
| | | import com.ximple.io.dgn7.ComplexChainElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.LineElement; |
| | | import com.ximple.io.dgn7.LineStringElement; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | |
| | | public class CreateLineTextStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | public class CreateLineTextStrategy implements CreateFeatureTypeStrategy { |
| | | static final Log logger = LogFactory.getLog(CreateLineTextStrategy.class); |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); |
| | | TreeMap<String, SimpleFeatureType> typeBuilders = new TreeMap<String, SimpleFeatureType>(); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public CreateLineTextStrategy() |
| | | { |
| | | public CreateLineTextStrategy() { |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createLineFeatureTypeBuilder(featureName); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, typeBuilder.getFeatureType())); |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException { |
| | | if (!typeBuilders.containsKey(featureName)) { |
| | | SimpleFeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createLineFeatureTypeBuilder(featureName); |
| | | SimpleFeatureType featureType = typeBuilder.buildFeatureType(); |
| | | typeBuilders.put(featureName, featureType); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, featureType)); |
| | | } |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | return typeBuilders.get(featureName); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException |
| | | { |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | FrammeAttributeData fLinkage = getFeatureLinkage(element); |
| | | Feature feature = null; |
| | | SimpleFeature feature = null; |
| | | if (fLinkage == null) return null; |
| | | if (element instanceof LineStringElement) |
| | | { |
| | | if (element instanceof LineStringElement) { |
| | | LineStringElement lineStringElement = (LineStringElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(lineStringElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else { |
| | | gobj = lineStringElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(lineStringElement.getColorIndex()), |
| | | (short) lineStringElement.getWeight(), |
| | | (short) lineStringElement.getLineStyle() |
| | | }); |
| | | } else if (element instanceof TextElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof TextElement) { |
| | | TextElement txtElement = (TextElement) element; |
| | | Coordinate ptOrigin = txtElement.getUserOrigin(); |
| | | Coordinate ptEnd = new Coordinate(); |
| | | ptEnd.x = ptOrigin.x; |
| | | ptEnd.y = ptOrigin.y + txtElement.getTextHeight(); |
| | | Coordinate[] vect = new Coordinate[2]; |
| | | if (useTransform) |
| | | { |
| | | vect[0] = TWDDatumConverter.fromTM2ToTWD97(ptOrigin); |
| | | vect[1] = TWDDatumConverter.fromTM2ToTWD97(ptEnd); |
| | | if (useTransform) { |
| | | vect[0] = (FeatureTypeBuilderUtil.getDefaultFeatureSRID() == 3826) ? |
| | | TWDDatumConverter.fromTM2ToEPSG3826(ptOrigin) : |
| | | TWDDatumConverter.fromTM2ToEPSG3825(ptOrigin); |
| | | vect[1] = FeatureTypeBuilderUtil.getDefaultFeatureSRID() == 3826 ? |
| | | TWDDatumConverter.fromTM2ToEPSG3826(ptEnd) : |
| | | TWDDatumConverter.fromTM2ToEPSG3825(ptEnd); |
| | | } else { |
| | | vect[0] = new Coordinate(ptOrigin); |
| | | vect[1] = new Coordinate(ptEnd); |
| | |
| | | |
| | | txtElement.getRotationAngle(); |
| | | |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | line, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(txtElement.getColorIndex()), |
| | | (short) txtElement.getWeight(), |
| | | (short) txtElement.getLineStyle() |
| | | }); |
| | | } else if (element instanceof ComplexChainElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof ComplexChainElement) { |
| | | ComplexChainElement complexChain = (ComplexChainElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(complexChain); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else { |
| | | gobj = complexChain.toGeometry(geometryFactory); |
| | | } |
| | | if ((gobj != null) && (gobj instanceof MultiLineString)) |
| | | { |
| | | if ((gobj != null) && (gobj instanceof MultiLineString)) { |
| | | MultiLineString mline = (MultiLineString) gobj; |
| | | CoordinateList coordinateList = new CoordinateList(); |
| | | if (mline.getNumGeometries() == 1) |
| | | { |
| | | for (int i = 0; i < mline.getNumGeometries(); i++) |
| | | { |
| | | if (mline.getNumGeometries() == 1) { |
| | | for (int i = 0; i < mline.getNumGeometries(); i++) { |
| | | coordinateList.add(mline.getGeometryN(i).getCoordinates(), true); |
| | | } |
| | | } |
| | |
| | | gobj = geometryFactory.createLineString(coordinateList.toCoordinateArray()); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(complexChain.getColorIndex()), |
| | | (short) complexChain.getWeight(), |
| | | (short) complexChain.getLineStyle() |
| | | }); |
| | | } else if (element instanceof LineElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof LineElement) { |
| | | LineElement lineElement = (LineElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(lineElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else { |
| | | gobj = lineElement.toGeometry(geometryFactory); |
| | | } |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(lineElement.getColorIndex()), |
| | | (short) lineElement.getWeight(), |
| | | (short) lineElement.getLineStyle() |
| | | }); |
| | | }, null); |
| | | } |
| | | |
| | | return feature; |
| | | } |
| | | |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.util.Assert; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.*; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.simple.SimpleFeatureBuilder; |
| | | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import com.ximple.eofms.util.TWD97GeometryConverterDecorator; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.GeometryConverter; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.TextNodeElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import javax.swing.event.EventListenerList; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | public class CreateMultiSymbolStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | public class CreateMultiSymbolStrategy implements CreateFeatureTypeStrategy { |
| | | static final Log logger = LogFactory.getLog(CreateMultiSymbolStrategy.class); |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | TWD97AnchorGeometryConverterDecorator convertDecorator = new TWD97AnchorGeometryConverterDecorator(); |
| | | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); |
| | | TreeMap<String, SimpleFeatureType> typeBuilders = new TreeMap<String, SimpleFeatureType>(); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public CreateMultiSymbolStrategy() |
| | | { |
| | | public CreateMultiSymbolStrategy() { |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createMultiSymbolFeatureTypeBuilder(featureName); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, typeBuilder.getFeatureType())); |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException { |
| | | if (!typeBuilders.containsKey(featureName)) { |
| | | SimpleFeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createMultiSymbolFeatureTypeBuilder(featureName); |
| | | SimpleFeatureType featureType = typeBuilder.buildFeatureType(); |
| | | typeBuilders.put(featureName, featureType); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, featureType)); |
| | | } |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | return typeBuilders.get(featureName); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException |
| | | { |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | FrammeAttributeData fLinkage = getFeatureLinkage(element); |
| | | Feature feature = null; |
| | | SimpleFeature feature = null; |
| | | if (fLinkage == null) return null; |
| | | if (element instanceof TextElement) |
| | | { |
| | | if (element instanceof TextElement) { |
| | | TextElement txtElement = (TextElement) element; |
| | | double angle = txtElement.getRotationAngle(); |
| | | angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue(); |
| | | if (txtElement.getText().length() == 0) |
| | | { |
| | | String content = txtElement.getText().trim(); |
| | | if (content.length() == 0) { |
| | | logger.info("CreateMultiSymbolStrategy cannot conver " + element.toString() + |
| | | "to Feature - getText() is empty."); |
| | | return null; |
| | | } |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("OCT"); |
| | | char id = txtElement.getText().toCharArray()[0]; |
| | | char id = content.toCharArray()[0]; |
| | | sb.append(Integer.toOctalString((int) id)); |
| | | sb.append("-"); |
| | | sb.append(txtElement.getFontIndex()); |
| | | |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(txtElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else { |
| | | gobj = txtElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | (float) txtElement.getTextWidth(), |
| | | (float) angle, |
| | | sb.toString() |
| | | }); |
| | | } else if (element instanceof TextNodeElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof TextNodeElement) { |
| | | TextNodeElement nodeElement = (TextNodeElement) element; |
| | | |
| | | double angle = nodeElement.getRotationAngle(); |
| | | angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue(); |
| | | if (nodeElement.size() == 0) |
| | | { |
| | | if (nodeElement.size() == 0) { |
| | | logger.info("CreateMultiSymbolStrategy cannot conver " + element.toString() + |
| | | "to Feature - getText() is empty."); |
| | | return null; |
| | | } |
| | | |
| | | String[] tmpstrs = nodeElement.getTextArray(); |
| | | Iterator<Element> txtElement = nodeElement.iterator(); |
| | | |
| | | while (txtElement.hasNext()) { |
| | | if (txtElement instanceof TextElement) { |
| | | TextElement txtChildElement = (TextElement) element; |
| | | char[] charArray = txtChildElement.getText().toCharArray(); |
| | | |
| | | |
| | | if (charArray.length == 0) { |
| | | logger.info("CreateMultiSymbolStrategy cannot conver " + element.toString() + |
| | | "to Feature - getText() is empty."); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | for (int i = 0; i < charArray.length; i++) { |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("OCT"); |
| | | char id = tmpstrs[0].toCharArray()[0]; |
| | | char id = charArray[i]; |
| | | sb.append(Integer.toOctalString((int) id)); |
| | | sb.append("-"); |
| | | sb.append(nodeElement.getFontIndex()); |
| | | sb.append(txtChildElement.getFontIndex()); |
| | | |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | convertDecorator.setConverter(nodeElement); |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(txtChildElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else { |
| | | gobj = nodeElement.toGeometry(geometryFactory); |
| | | gobj = txtChildElement.toGeometry(geometryFactory); |
| | | } |
| | | |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | | fLinkage.getOccID(), |
| | | (short) nodeElement.getLevelIndex(), |
| | | (short) txtChildElement.getLevelIndex(), |
| | | colorTable.getColorCode(nodeElement.getColorIndex()), |
| | | (short) nodeElement.getWeight(), |
| | | (short) nodeElement.getLineStyle(), |
| | | (short) nodeElement.getJustification(), |
| | | (float) nodeElement.getTextNodeHeight(), |
| | | (float) nodeElement.getTextNodeLength(), |
| | | (short) txtChildElement.getWeight(), |
| | | (short) txtChildElement.getLineStyle(), |
| | | (short) txtChildElement.getJustification(), |
| | | (float) txtChildElement.getTextHeight(), |
| | | (float) txtChildElement.getTextWidth(), |
| | | (float) angle, |
| | | sb.toString() |
| | | }); |
| | | } else |
| | | { |
| | | }, null); |
| | | } |
| | | } else { |
| | | logger.info("CreateMultiSymbolStrategy cannot conver " + element.toString() + "to Feature"); |
| | | return null; |
| | | } |
| | | } |
| | | } else { |
| | | logger.info("CreateMultiSymbolStrategy cannot conver " + element.toString() + "to Feature"); |
| | | return null; |
| | | } |
| | | return feature; |
| | | } |
| | | |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static class TWD97AnchorGeometryConverterDecorator extends TWD97GeometryConverterDecorator |
| | | { |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | | { |
| | | private static class EPSG3826AnchorGeometryConverterDecorator extends EPSG3826GeometryConverterDecorator { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | if (getConverter() == null) Assert.shouldNeverReachHere(); |
| | | |
| | | getCoordinatesFilter().reset(); |
| | | |
| | | GeometryConverter converter = getConverter(); |
| | | Geometry geom = null; |
| | | try |
| | | { |
| | | if (converter instanceof TextElement) |
| | | { |
| | | try { |
| | | if (converter instanceof TextElement) { |
| | | geom = ((TextElement) converter).toAnchorGeometry(factory); |
| | | } else if (converter instanceof TextNodeElement) |
| | | { |
| | | } else if (converter instanceof TextNodeElement) { |
| | | geom = ((TextNodeElement) converter).toAnchorGeometry(factory); |
| | | } |
| | | } catch (ArrayStoreException e) |
| | | { |
| | | } catch (ArrayStoreException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | if (converter instanceof TextNodeElement) |
| | | { |
| | | if (converter instanceof TextNodeElement) { |
| | | TextNodeElement node = (TextNodeElement) converter; |
| | | CoordinateList pts = new CoordinateList(); |
| | | for (int i = 0; i < node.size(); i++) |
| | | { |
| | | for (int i = 0; i < node.size(); i++) { |
| | | TextElement txtElm = (TextElement) node.get(i); |
| | | Coordinate[] coords = txtElm.toAnchorCoordinates(); |
| | | logger.warn("-coords=[" + coords.length + "]"); |
| | | for (int j = 0; j < coords.length; j++) |
| | | { |
| | | for (int j = 0; j < coords.length; j++) { |
| | | logger.warn("[" + j + "]-" + coords.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (geom == null) return null; |
| | | geom.apply(getCoordinatesFilter()); |
| | | return geom; |
| | | } |
| | | } |
| | | |
| | | private static class EPSG3825AnchorGeometryConverterDecorator extends EPSG3825GeometryConverterDecorator { |
| | | public Geometry toGeometry(GeometryFactory factory) { |
| | | if (getConverter() == null) Assert.shouldNeverReachHere(); |
| | | |
| | | getCoordinatesFilter().reset(); |
| | | |
| | | GeometryConverter converter = getConverter(); |
| | | Geometry geom = null; |
| | | try { |
| | | if (converter instanceof TextElement) { |
| | | geom = ((TextElement) converter).toAnchorGeometry(factory); |
| | | } else if (converter instanceof TextNodeElement) { |
| | | geom = ((TextNodeElement) converter).toAnchorGeometry(factory); |
| | | } |
| | | } catch (ArrayStoreException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | if (converter instanceof TextNodeElement) { |
| | | TextNodeElement node = (TextNodeElement) converter; |
| | | CoordinateList pts = new CoordinateList(); |
| | | for (int i = 0; i < node.size(); i++) { |
| | | TextElement txtElm = (TextElement) node.get(i); |
| | | Coordinate[] coords = txtElm.toAnchorCoordinates(); |
| | | logger.warn("-coords=[" + coords.length + "]"); |
| | | for (int j = 0; j < coords.length; j++) { |
| | | logger.warn("[" + j + "]-" + coords.toString()); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.*; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.simple.SimpleFeatureBuilder; |
| | | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import com.ximple.eofms.util.TWD97GeometryConverterDecorator; |
| | | import com.ximple.io.dgn7.ComplexShapeElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.ShapeElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import javax.swing.event.EventListenerList; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | public class CreateShapeStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | public class CreateShapeStrategy implements CreateFeatureTypeStrategy { |
| | | static final Log logger = LogFactory.getLog(CreateShapeStrategy.class); |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); |
| | | TreeMap<String, SimpleFeatureType> typeBuilders = new TreeMap<String, SimpleFeatureType>(); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public CreateShapeStrategy() |
| | | { |
| | | public CreateShapeStrategy() { |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createPolygonFeatureTypeBuilder(featureName); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, typeBuilder.getFeatureType())); |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException { |
| | | if (!typeBuilders.containsKey(featureName)) { |
| | | SimpleFeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createPolygonFeatureTypeBuilder(featureName); |
| | | SimpleFeatureType featureType = typeBuilder.buildFeatureType(); |
| | | typeBuilders.put(featureName, featureType); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, featureType)); |
| | | } |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | return typeBuilders.get(featureName); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException |
| | | { |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | FrammeAttributeData fLinkage = getFeatureLinkage(element); |
| | | Feature feature = null; |
| | | SimpleFeature feature = null; |
| | | if (fLinkage == null) return null; |
| | | if (element instanceof ShapeElement) |
| | | { |
| | | if (element instanceof ShapeElement) { |
| | | ShapeElement shapeElement = (ShapeElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(shapeElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = shapeElement.toGeometry(geometryFactory); |
| | | } |
| | | |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(shapeElement.getColorIndex()), |
| | | (short) shapeElement.getWeight(), |
| | | (short) shapeElement.getLineStyle() |
| | | }); |
| | | } else if (element instanceof ComplexShapeElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof ComplexShapeElement) { |
| | | ComplexShapeElement complexShape = (ComplexShapeElement) element; |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(complexShape); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = complexShape.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | colorTable.getColorCode(complexShape.getColorIndex()), |
| | | (short) complexShape.getWeight(), |
| | | (short) complexShape.getLineStyle() |
| | | }); |
| | | }, null); |
| | | } |
| | | return feature; |
| | | } |
| | | |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.Envelope; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import com.ximple.eofms.util.TWD97GeometryConverterDecorator; |
| | | import com.vividsolutions.jts.geom.Point; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.simple.SimpleFeatureBuilder; |
| | | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | public class CreateSymbolStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | import javax.swing.event.EventListenerList; |
| | | import java.awt.geom.AffineTransform; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | public class CreateSymbolStrategy implements CreateFeatureTypeStrategy { |
| | | static final Log logger = LogFactory.getLog(CreateSymbolStrategy.class); |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); |
| | | TreeMap<String, SimpleFeatureType> typeBuilders = new TreeMap<String, SimpleFeatureType>(); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public CreateSymbolStrategy() |
| | | { |
| | | public CreateSymbolStrategy() { |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createSymbolFeatureTypeBuilder(featureName); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, typeBuilder.getFeatureType())); |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException { |
| | | if (!typeBuilders.containsKey(featureName)) { |
| | | SimpleFeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createSymbolFeatureTypeBuilder(featureName); |
| | | SimpleFeatureType featureType = typeBuilder.buildFeatureType(); |
| | | typeBuilders.put(featureName, featureType); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, featureType)); |
| | | } |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | return typeBuilders.get(featureName); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException |
| | | { |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | FrammeAttributeData fLinkage = getFeatureLinkage(element); |
| | | Feature feature = null; |
| | | SimpleFeature feature = null; |
| | | if (fLinkage == null) return null; |
| | | if (element instanceof TextElement) |
| | | { |
| | | if (element instanceof TextElement) { |
| | | TextElement txtElement = (TextElement) element; |
| | | double angle = txtElement.getRotationAngle(); |
| | | angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue(); |
| | | if (txtElement.getText().length() == 0) |
| | | { |
| | | if (txtElement.getText().length() == 0) { |
| | | logger.info("CreateSymbolStrategy cannot conver " + element.toString() + |
| | | "to Feature - getText() is empty."); |
| | | return null; |
| | |
| | | sb.append("-"); |
| | | sb.append(txtElement.getFontIndex()); |
| | | |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | Geometry gobj, geomOrigin = null; |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(txtElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = txtElement.toGeometry(geometryFactory); |
| | | } |
| | | |
| | | if (gobj instanceof Point) { |
| | | geomOrigin = gobj; |
| | | Coordinate originPt = gobj.getCoordinate(); |
| | | gobj = buildBoundaryPolygon(originPt, // txtElement.getOrigin() |
| | | txtElement.getTextWidth(), txtElement.getTextHeight(), |
| | | angle, txtElement.getJustification(), gobj.getSRID()); |
| | | } else { |
| | | gobj = null; |
| | | } |
| | | |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | (float) txtElement.getTextHeight(), |
| | | (float) txtElement.getTextWidth(), |
| | | (float) angle, |
| | | sb.toString() |
| | | }); |
| | | } else |
| | | { |
| | | sb.toString(), |
| | | geomOrigin |
| | | }, null); |
| | | } else { |
| | | logger.info("CreateSymbolStrategy cannot conver " + element.toString() + "to Feature"); |
| | | } |
| | | return feature; |
| | | } |
| | | |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private Geometry buildBoundaryPolygon(Coordinate p, double symbolWidth, double symbolHeight, double rotationAngle, |
| | | int justification, int srid) { |
| | | double angle = Math.toRadians(rotationAngle); |
| | | |
| | | AffineTransform at = new AffineTransform(); |
| | | // at.translate(width, height); |
| | | at.setToRotation(angle, p.x, p.y); |
| | | at.scale(1, 1); |
| | | |
| | | double width = symbolWidth; |
| | | switch (justification) { |
| | | case TextElement.TXTJUST_LT: |
| | | case TextElement.TXTJUST_LC: |
| | | case TextElement.TXTJUST_LB: |
| | | width = width / 2; |
| | | break; |
| | | |
| | | case TextElement.TXTJUST_CT: |
| | | case TextElement.TXTJUST_CC: |
| | | case TextElement.TXTJUST_CB: |
| | | width = 0; |
| | | break; |
| | | |
| | | case TextElement.TXTJUST_RT: |
| | | case TextElement.TXTJUST_RC: |
| | | case TextElement.TXTJUST_RB: |
| | | width = -(width / 2); |
| | | break; |
| | | } |
| | | |
| | | double height = symbolHeight; |
| | | switch (justification) { |
| | | case TextElement.TXTJUST_LB: |
| | | case TextElement.TXTJUST_CB: |
| | | case TextElement.TXTJUST_RB: // bottom |
| | | height = height / 2; |
| | | break; |
| | | |
| | | case TextElement.TXTJUST_LC: |
| | | case TextElement.TXTJUST_CC: |
| | | case TextElement.TXTJUST_RC: // center |
| | | height = 0; |
| | | break; |
| | | |
| | | case TextElement.TXTJUST_LT: |
| | | case TextElement.TXTJUST_CT: |
| | | case TextElement.TXTJUST_RT: // height |
| | | height = -(height / 2); |
| | | break; |
| | | } |
| | | |
| | | |
| | | Envelope envelope = new Envelope(new Coordinate(p.x + width, p.y + height)); |
| | | envelope.expandBy(symbolWidth / 2, symbolHeight / 2); |
| | | |
| | | double[] srcPt = new double[8]; |
| | | double[] dstPt = new double[8]; |
| | | srcPt[0] = envelope.getMinX(); |
| | | srcPt[1] = envelope.getMinY(); |
| | | srcPt[2] = envelope.getMinX(); |
| | | srcPt[3] = envelope.getMaxY(); |
| | | srcPt[4] = envelope.getMaxX(); |
| | | srcPt[5] = envelope.getMaxY(); |
| | | srcPt[6] = envelope.getMaxX(); |
| | | srcPt[7] = envelope.getMinY(); |
| | | |
| | | at.transform(srcPt, 0, dstPt, 0, 4); |
| | | |
| | | Coordinate[] coords = new Coordinate[5]; |
| | | for (int i = 0; i < 4; i++) { |
| | | coords[i] = new Coordinate(dstPt[i*2], dstPt[i*2+1]); |
| | | } |
| | | coords[4] = new Coordinate(dstPt[0], dstPt[1]); |
| | | |
| | | Geometry geom = geometryFactory.createPolygon(geometryFactory.createLinearRing(coords), null); |
| | | if (geom.getSRID() != srid) { |
| | | geom.setSRID(srid); |
| | | } |
| | | return geom; |
| | | } |
| | | } |
| | | |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.*; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.simple.SimpleFeatureBuilder; |
| | | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; |
| | | import org.geotools.geometry.jts.JTSFactoryFinder; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | import javax.swing.event.EventListenerList; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | import javax.swing.event.EventListenerList; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.FeatureTypeBuilder; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | import com.ximple.eofms.util.DefaultColorTable; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import com.ximple.eofms.util.TWD97GeometryConverterDecorator; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.io.dgn7.TextNodeElement; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | |
| | | public class CreateTextStrategy implements CreateFeatureTypeStrategy |
| | | { |
| | | public class CreateTextStrategy implements CreateFeatureTypeStrategy { |
| | | static final Log logger = LogFactory.getLog(CreateTextStrategy.class); |
| | | GeometryFactory geometryFactory = new GeometryFactory(); |
| | | TreeMap<String, FeatureTypeBuilder> typeBuilders = new TreeMap<String, FeatureTypeBuilder>(); |
| | | TWD97GeometryConverterDecorator convertDecorator = new TWD97GeometryConverterDecorator(); |
| | | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); |
| | | TreeMap<String, SimpleFeatureType> typeBuilders = new TreeMap<String, SimpleFeatureType>(); |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public CreateTextStrategy() |
| | | { |
| | | public CreateTextStrategy() { |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public FeatureType createFeatureElement(String featureName) throws SchemaException |
| | | { |
| | | if (!typeBuilders.containsKey(featureName)) |
| | | { |
| | | FeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createPointFeatureTypeBuilder(featureName); |
| | | typeBuilders.put(featureName, typeBuilder); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, typeBuilder.getFeatureType())); |
| | | public SimpleFeatureType createFeatureElement(String featureName) throws SchemaException { |
| | | if (!typeBuilders.containsKey(featureName)) { |
| | | SimpleFeatureTypeBuilder typeBuilder = FeatureTypeBuilderUtil.createPointFeatureTypeBuilder(featureName); |
| | | SimpleFeatureType featureType = typeBuilder.buildFeatureType(); |
| | | typeBuilders.put(featureName, featureType); |
| | | fireFeatureTypeEvent(new FeatureTypeEvent(this, featureType)); |
| | | } |
| | | return typeBuilders.get(featureName).getFeatureType(); |
| | | return typeBuilders.get(featureName); |
| | | } |
| | | |
| | | public Feature createFeature(FeatureType featureType, Element element, boolean useTransform) throws IllegalAttributeException |
| | | { |
| | | public SimpleFeature createFeature(SimpleFeatureType featureType, Element element, |
| | | short distId, boolean useTransform) throws IllegalAttributeException { |
| | | DefaultColorTable colorTable = (DefaultColorTable) DefaultColorTable.getInstance(); |
| | | FrammeAttributeData fLinkage = getFeatureLinkage(element); |
| | | Feature feature = null; |
| | | SimpleFeature feature = null; |
| | | if (fLinkage == null) return null; |
| | | if (element instanceof TextElement) |
| | | { |
| | | if (element instanceof TextElement) { |
| | | TextElement txtElement = (TextElement) element; |
| | | double angle = txtElement.getRotationAngle(); |
| | | angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue(); |
| | | String content = txtElement.getText(); |
| | | content = content.replace('\u0000', ' '); |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(txtElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = txtElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | (float) txtElement.getTextWidth(), |
| | | (float) angle, |
| | | content |
| | | }); |
| | | } else if (element instanceof TextNodeElement) |
| | | { |
| | | }, null); |
| | | } else if (element instanceof TextNodeElement) { |
| | | TextNodeElement nodeElement = (TextNodeElement) element; |
| | | String[] texts = nodeElement.getTextArray(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (String text : texts) |
| | | { |
| | | for (String text : texts) { |
| | | if (sb.length() != 0) |
| | | sb.append("\n"); |
| | | String content = text.replace('\u0000', ' '); |
| | |
| | | double angle = nodeElement.getRotationAngle(); |
| | | angle = BigDecimal.valueOf(angle).setScale(3, RoundingMode.HALF_UP).doubleValue(); |
| | | Geometry gobj; |
| | | if (useTransform) |
| | | { |
| | | if (useTransform) { |
| | | GeometryConverterDecorator convertDecorator = FeatureTypeBuilderUtil.lookupDefaultGeometryConverter(); |
| | | convertDecorator.setConverter(nodeElement); |
| | | gobj = convertDecorator.toGeometry(geometryFactory); |
| | | } else |
| | | { |
| | | } else { |
| | | gobj = nodeElement.toGeometry(geometryFactory); |
| | | } |
| | | if (gobj != null) |
| | | feature = featureType.create(new Object[]{ |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |
| | | distId, |
| | | fLinkage.getFsc(), |
| | | (long) fLinkage.getUfid(), |
| | | (short) fLinkage.getComponentID(), |
| | |
| | | (float) nodeElement.getTextNodeLength(), |
| | | (float) angle, |
| | | sb.toString() |
| | | }); |
| | | }, null); |
| | | } |
| | | return feature; |
| | | } |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import org.geotools.feature.Feature; |
| | | |
| | | import com.ximple.io.dgn7.Element; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | |
| | | public interface ElementDispatchableFilter |
| | | { |
| | | public interface ElementDispatchableFilter { |
| | | public boolean isDispatchable(Element element); |
| | | |
| | | public Feature execute(Element element, boolean useTransform); |
| | | public SimpleFeature execute(Element element, short distId, boolean useTransform); |
| | | |
| | | void setUseLongName(boolean useLongName); |
| | | |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.LinkedList; |
| | | import com.ximple.io.dgn7.Element; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | |
| | | import javax.swing.event.EventListenerList; |
| | | import java.util.LinkedList; |
| | | |
| | | import org.geotools.feature.Feature; |
| | | |
| | | import com.ximple.io.dgn7.Element; |
| | | |
| | | public class ElementDispatcher implements CreateFeatureTypeEventListener |
| | | { |
| | | public class ElementDispatcher implements CreateFeatureTypeEventListener { |
| | | private LinkedList<ElementDispatchableFilter> rules; |
| | | private boolean useLongName = false; |
| | | |
| | | // Create the listener list |
| | | protected EventListenerList listenerList = new EventListenerList(); |
| | | |
| | | public ElementDispatcher() |
| | | { |
| | | public ElementDispatcher() { |
| | | rules = new LinkedList<ElementDispatchableFilter>(); |
| | | } |
| | | |
| | | public LinkedList<ElementDispatchableFilter> getRules() |
| | | { |
| | | public LinkedList<ElementDispatchableFilter> getRules() { |
| | | return rules; |
| | | } |
| | | |
| | | public void addRule(ElementDispatchableFilter rule) |
| | | { |
| | | public void addRule(ElementDispatchableFilter rule) { |
| | | rule.setUseLongName(useLongName); |
| | | rule.addCreateFeatureTypeEventListener(this); |
| | | rules.add(rule); |
| | | } |
| | | |
| | | public boolean isUseLongName() |
| | | { |
| | | public boolean isUseLongName() { |
| | | return useLongName; |
| | | } |
| | | |
| | | public void setUseLongName(boolean useLongName) |
| | | { |
| | | if (this.useLongName != useLongName) |
| | | { |
| | | public void setUseLongName(boolean useLongName) { |
| | | if (this.useLongName != useLongName) { |
| | | this.useLongName = useLongName; |
| | | for (ElementDispatchableFilter filter : rules) |
| | | { |
| | | for (ElementDispatchableFilter filter : rules) { |
| | | filter.setUseLongName(useLongName); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public Feature execute(Element element, boolean useTransform) |
| | | { |
| | | for (ElementDispatchableFilter rule : rules) |
| | | { |
| | | if (rule.isDispatchable(element)) |
| | | { |
| | | return rule.execute(element, useTransform); |
| | | public SimpleFeature execute(Element element, short distId, boolean useTransform) { |
| | | for (ElementDispatchableFilter rule : rules) { |
| | | if (rule.isDispatchable(element)) { |
| | | return rule.execute(element, distId, useTransform); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void addCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.add(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) |
| | | { |
| | | public void removeCreateFeatureTypeEventListener(CreateFeatureTypeEventListener listener) { |
| | | listenerList.remove(CreateFeatureTypeEventListener.class, listener); |
| | | } |
| | | |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) |
| | | { |
| | | protected void fireFeatureTypeEvent(FeatureTypeEvent evt) { |
| | | Object[] listeners = listenerList.getListenerList(); |
| | | for (int i = 0; i < listeners.length; i += 2) |
| | | { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) |
| | | { |
| | | for (int i = 0; i < listeners.length; i += 2) { |
| | | if (listeners[i] == CreateFeatureTypeEventListener.class) { |
| | | ((CreateFeatureTypeEventListener) listeners[i + 1]).createFeatureTypeOccurred(evt); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void createFeatureTypeOccurred(FeatureTypeEvent evt) |
| | | { |
| | | public void createFeatureTypeOccurred(FeatureTypeEvent evt) { |
| | | fireFeatureTypeEvent(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import com.ximple.io.dgn7.Element; |
| | | |
| | | public class ElementLevelCriterion implements Comparable |
| | | { |
| | | import java.util.ArrayList; |
| | | |
| | | public class ElementLevelCriterion implements Comparable { |
| | | private int elementLevel; |
| | | private ArrayList<Integer> elementLevelArray; |
| | | |
| | | public ElementLevelCriterion() |
| | | { |
| | | public ElementLevelCriterion() { |
| | | elementLevelArray = new ArrayList<Integer>(); |
| | | } |
| | | |
| | | public int compareTo(Object o) |
| | | { |
| | | if (o instanceof Element) |
| | | { |
| | | public int compareTo(Object o) { |
| | | if (o instanceof Element) { |
| | | Element elm = (Element) o; |
| | | |
| | | for (Integer elevel : getElementLevelArray()) |
| | | { |
| | | if (elm.getElementType().id == elevel.intValue()) |
| | | for (Integer elevel : getElementLevelArray()) { |
| | | if (elm.getElementType().id == elevel) |
| | | return 0; |
| | | } |
| | | |
| | |
| | | return -1; |
| | | } |
| | | |
| | | public int getElementLevel() |
| | | { |
| | | public int getElementLevel() { |
| | | return elementLevel; |
| | | } |
| | | |
| | | public ArrayList<Integer> getElementLevelArray() |
| | | { |
| | | public ArrayList<Integer> getElementLevelArray() { |
| | | return elementLevelArray; |
| | | } |
| | | |
| | | public void setElementLevel(int iLevel) |
| | | { |
| | | public void setElementLevel(int iLevel) { |
| | | this.elementLevel = iLevel; |
| | | this.elementLevelArray.add(iLevel); |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import com.ximple.io.dgn7.Element; |
| | | |
| | | public class ElementTypeCriterion implements Comparable |
| | | { |
| | | import java.util.ArrayList; |
| | | |
| | | public class ElementTypeCriterion implements Comparable { |
| | | private int elementType; |
| | | private ArrayList<Integer> elementTypeArray; |
| | | |
| | | public ElementTypeCriterion() |
| | | { |
| | | public ElementTypeCriterion() { |
| | | elementTypeArray = new ArrayList<Integer>(); |
| | | } |
| | | |
| | | public int compareTo(Object o) |
| | | { |
| | | if (o instanceof Element) |
| | | { |
| | | public int compareTo(Object o) { |
| | | if (o instanceof Element) { |
| | | Element elm = (Element) o; |
| | | |
| | | for (Integer etype : getElementTypeArray()) |
| | | { |
| | | for (Integer etype : getElementTypeArray()) { |
| | | if (elm.getElementType().id == etype.intValue()) |
| | | return 0; |
| | | } |
| | |
| | | return -1; |
| | | } |
| | | |
| | | public int getElementType() |
| | | { |
| | | public int getElementType() { |
| | | return elementType; |
| | | } |
| | | |
| | | public ArrayList<Integer> getElementTypeArray() |
| | | { |
| | | public ArrayList<Integer> getElementTypeArray() { |
| | | return elementTypeArray; |
| | | } |
| | | |
| | | public void setElementType(int itype) |
| | | { |
| | | public void setElementType(int itype) { |
| | | this.elementType = itype; |
| | | this.elementTypeArray.add(itype); |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | import java.util.EventObject; |
| | | |
| | | import org.geotools.feature.FeatureType; |
| | | |
| | | public class FeatureTypeEvent extends EventObject |
| | | { |
| | | private FeatureType featureType; |
| | | public class FeatureTypeEvent extends EventObject { |
| | | private SimpleFeatureType featureType; |
| | | |
| | | /** |
| | | * Constructs a prototypical Event. |
| | |
| | | * @param featureType featureType |
| | | * @throws IllegalArgumentException if source is null. |
| | | */ |
| | | public FeatureTypeEvent(Object source, FeatureType featureType) |
| | | { |
| | | public FeatureTypeEvent(Object source, SimpleFeatureType featureType) { |
| | | super(source); |
| | | this.featureType = featureType; |
| | | } |
| | | |
| | | public FeatureType getFeatureType() |
| | | { |
| | | public SimpleFeatureType getFeatureType() { |
| | | return featureType; |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.ximple.eofms.util.StringUtils; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.eofms.util.StringUtils; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | public class TypeCompIdDispatchableFilter extends AbstractFLinkageDispatchableFilter |
| | | implements CreateFeatureTypeEventListener |
| | | { |
| | | implements CreateFeatureTypeEventListener { |
| | | private int tid; |
| | | private int cid; |
| | | private CreateFeatureTypeStrategy createStrategy; |
| | | private boolean useLongName = false; |
| | | |
| | | public TypeCompIdDispatchableFilter() |
| | | { |
| | | public TypeCompIdDispatchableFilter() { |
| | | } |
| | | |
| | | public TypeCompIdDispatchableFilter(String fname, |
| | | CreateFeatureTypeStrategy createStrategy, |
| | | int tid, int compid) |
| | | { |
| | | int tid, int compid) { |
| | | this.setName(fname); |
| | | this.tid = tid; |
| | | this.cid = compid; |
| | |
| | | this.createStrategy.addCreateFeatureTypeEventListener(this); |
| | | } |
| | | |
| | | public int getTid() |
| | | { |
| | | public int getTid() { |
| | | return tid; |
| | | } |
| | | |
| | | public void setTid(int tid) |
| | | { |
| | | public void setTid(int tid) { |
| | | this.tid = tid; |
| | | } |
| | | |
| | | public int getCid() |
| | | { |
| | | public int getCid() { |
| | | return cid; |
| | | } |
| | | |
| | | public void setCid(int cid) |
| | | { |
| | | public void setCid(int cid) { |
| | | this.cid = cid; |
| | | } |
| | | |
| | | public CreateFeatureTypeStrategy getCreateStrategy() |
| | | { |
| | | public CreateFeatureTypeStrategy getCreateStrategy() { |
| | | return createStrategy; |
| | | } |
| | | |
| | | public void setCreateStrategy(CreateFeatureTypeStrategy createStrategy) |
| | | { |
| | | if (this.createStrategy != null) |
| | | { |
| | | public void setCreateStrategy(CreateFeatureTypeStrategy createStrategy) { |
| | | if (this.createStrategy != null) { |
| | | this.createStrategy.removeCreateFeatureTypeEventListener(this); |
| | | } |
| | | this.createStrategy = createStrategy; |
| | | |
| | | if (this.createStrategy != null) |
| | | { |
| | | if (this.createStrategy != null) { |
| | | this.createStrategy.addCreateFeatureTypeEventListener(this); |
| | | } |
| | | } |
| | | |
| | | public boolean isUseLongName() |
| | | { |
| | | public boolean isUseLongName() { |
| | | return useLongName; |
| | | } |
| | | |
| | | public void setUseLongName(boolean useLongName) |
| | | { |
| | | public void setUseLongName(boolean useLongName) { |
| | | this.useLongName = useLongName; |
| | | } |
| | | |
| | | //§PÂ_¬O§_²Å©M±ø¥ó |
| | | public boolean isDispatchable(Element element) |
| | | { |
| | | //�P�_�O�_�ũM��� |
| | | public boolean isDispatchable(Element element) { |
| | | FrammeAttributeData featureLinkage = getFeatureLinkage(element); |
| | | return featureLinkage != null && tid == featureLinkage.getFsc() && |
| | | (cid == featureLinkage.getComponentID()) && |
| | | (compareType(element) == 0); |
| | | } |
| | | |
| | | public Feature execute(Element element, boolean useTransform) |
| | | { |
| | | try |
| | | { |
| | | public SimpleFeature execute(Element element, short distId, boolean useTransform) { |
| | | try { |
| | | String ftName = getFeatureTypeName(element); |
| | | FeatureType ftype = createStrategy.createFeatureElement(ftName); |
| | | return createStrategy.createFeature(ftype, element, useTransform); |
| | | } catch (SchemaException e) |
| | | { |
| | | SimpleFeatureType ftype = createStrategy.createFeatureElement(ftName); |
| | | return createStrategy.createFeature(ftype, element, distId, useTransform); |
| | | } catch (SchemaException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | } catch (IllegalAttributeException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (NullPointerException e) |
| | | { |
| | | } catch (NullPointerException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getFeatureTypeName(Element element) |
| | | { |
| | | public String getFeatureTypeName(Element element) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | String name = getName().toLowerCase(); |
| | | String[] pices = StringUtils.splitToArray(name, "."); |
| | | boolean bfirst = true; |
| | | for (String temp : pices) |
| | | { |
| | | for (String temp : pices) { |
| | | if (bfirst) bfirst = false; |
| | | else sb.append('-'); |
| | | sb.append(temp); |
| | | } |
| | | if (useLongName) |
| | | { |
| | | if (useLongName) { |
| | | sb.append("_"); |
| | | sb.append(element.getLevelIndex()); |
| | | sb.append("_"); |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public void createFeatureTypeOccurred(FeatureTypeEvent evt) |
| | | { |
| | | public void createFeatureTypeOccurred(FeatureTypeEvent evt) { |
| | | fireFeatureTypeEvent(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.ximple.eofms.util.StringUtils; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.eofms.util.StringUtils; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | public class TypeCompLevelIdDispatchableFilter extends AbstractFLinkageDispatchableFilter |
| | | implements CreateFeatureTypeEventListener |
| | | { |
| | | implements CreateFeatureTypeEventListener { |
| | | private int tid; |
| | | private int cid; |
| | | private int lid; |
| | | private CreateFeatureTypeStrategy createStrategy; |
| | | private boolean useLongName = false; |
| | | |
| | | public TypeCompLevelIdDispatchableFilter() |
| | | { |
| | | public TypeCompLevelIdDispatchableFilter() { |
| | | } |
| | | |
| | | public TypeCompLevelIdDispatchableFilter(String fname, |
| | | CreateFeatureTypeStrategy createStrategy, |
| | | int tid, int compid, int level) |
| | | { |
| | | int tid, int compid, int level) { |
| | | this.setName(fname); |
| | | this.tid = tid; |
| | | this.cid = compid; |
| | |
| | | this.createStrategy.addCreateFeatureTypeEventListener(this); |
| | | } |
| | | |
| | | public int getTid() |
| | | { |
| | | public int getTid() { |
| | | return tid; |
| | | } |
| | | |
| | | public void setTid(int tid) |
| | | { |
| | | public void setTid(int tid) { |
| | | this.tid = tid; |
| | | } |
| | | |
| | | public int getCid() |
| | | { |
| | | public int getCid() { |
| | | return cid; |
| | | } |
| | | |
| | | public void setCid(int cid) |
| | | { |
| | | public void setCid(int cid) { |
| | | this.cid = cid; |
| | | } |
| | | |
| | | public int getLid() |
| | | { |
| | | public int getLid() { |
| | | return lid; |
| | | } |
| | | |
| | | public void setLid(int lid) |
| | | { |
| | | public void setLid(int lid) { |
| | | this.lid = lid; |
| | | } |
| | | |
| | | public CreateFeatureTypeStrategy getCreateStrategy() |
| | | { |
| | | public CreateFeatureTypeStrategy getCreateStrategy() { |
| | | return createStrategy; |
| | | } |
| | | |
| | | public void setCreateStrategy(CreateFeatureTypeStrategy createStrategy) |
| | | { |
| | | if (this.createStrategy != null) |
| | | { |
| | | public void setCreateStrategy(CreateFeatureTypeStrategy createStrategy) { |
| | | if (this.createStrategy != null) { |
| | | this.createStrategy.removeCreateFeatureTypeEventListener(this); |
| | | } |
| | | this.createStrategy = createStrategy; |
| | | |
| | | if (this.createStrategy != null) |
| | | { |
| | | if (this.createStrategy != null) { |
| | | this.createStrategy.addCreateFeatureTypeEventListener(this); |
| | | } |
| | | } |
| | | |
| | | |
| | | public boolean isUseLongName() |
| | | { |
| | | public boolean isUseLongName() { |
| | | return useLongName; |
| | | } |
| | | |
| | | public void setUseLongName(boolean useLongName) |
| | | { |
| | | public void setUseLongName(boolean useLongName) { |
| | | this.useLongName = useLongName; |
| | | } |
| | | |
| | | public boolean isDispatchable(Element element) |
| | | { |
| | | public boolean isDispatchable(Element element) { |
| | | FrammeAttributeData featureLinkage = getFeatureLinkage(element); |
| | | return featureLinkage != null && tid == featureLinkage.getFsc() && |
| | | (cid == featureLinkage.getComponentID()) && |
| | | (lid == element.getLevelIndex()) && (compareLevel(element) == 0); |
| | | } |
| | | |
| | | public Feature execute(Element element, boolean useTransform) |
| | | { |
| | | try |
| | | { |
| | | public SimpleFeature execute(Element element, short distId, boolean useTransform) { |
| | | try { |
| | | String ftName = getFeatureTypeName(element); |
| | | FeatureType ftype = createStrategy.createFeatureElement(ftName); |
| | | return createStrategy.createFeature(ftype, element, useTransform); |
| | | } catch (SchemaException e) |
| | | { |
| | | SimpleFeatureType ftype = createStrategy.createFeatureElement(ftName); |
| | | return createStrategy.createFeature(ftype, element, distId, useTransform); |
| | | } catch (SchemaException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | } catch (IllegalAttributeException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getFeatureTypeName(Element element) |
| | | { |
| | | public String getFeatureTypeName(Element element) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | String name = getName().toLowerCase(); |
| | | String[] pices = StringUtils.splitToArray(name, "."); |
| | | boolean bfirst = true; |
| | | for (String temp : pices) |
| | | { |
| | | for (String temp : pices) { |
| | | if (bfirst) bfirst = false; |
| | | else sb.append('-'); |
| | | sb.append(temp); |
| | | } |
| | | if (useLongName) |
| | | { |
| | | if (useLongName) { |
| | | sb.append("_"); |
| | | sb.append(element.getLevelIndex()); |
| | | sb.append("_"); |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public void createFeatureTypeOccurred(FeatureTypeEvent evt) |
| | | { |
| | | public void createFeatureTypeOccurred(FeatureTypeEvent evt) { |
| | | fireFeatureTypeEvent(evt); |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | |
| | | import com.ximple.eofms.util.StringUtils; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.eofms.util.StringUtils; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | public class TypeIdDispatchableFilter extends AbstractFLinkageDispatchableFilter implements CreateFeatureTypeEventListener |
| | | { |
| | | public class TypeIdDispatchableFilter extends AbstractFLinkageDispatchableFilter implements CreateFeatureTypeEventListener { |
| | | private int tid; |
| | | private CreateFeatureTypeStrategy createStrategy; |
| | | private boolean useLongName = false; |
| | | |
| | | public TypeIdDispatchableFilter() |
| | | { |
| | | public TypeIdDispatchableFilter() { |
| | | } |
| | | |
| | | public TypeIdDispatchableFilter(String fname, CreateFeatureTypeStrategy createStrategy, |
| | | int tid) |
| | | { |
| | | int tid) { |
| | | this.setName(fname); |
| | | this.tid = tid; |
| | | this.createStrategy = createStrategy; |
| | | this.createStrategy.addCreateFeatureTypeEventListener(this); |
| | | } |
| | | |
| | | public int getTid() |
| | | { |
| | | public int getTid() { |
| | | return tid; |
| | | } |
| | | |
| | | public void setTid(int tid) |
| | | { |
| | | public void setTid(int tid) { |
| | | this.tid = tid; |
| | | } |
| | | |
| | | public CreateFeatureTypeStrategy getCreateStrategy() |
| | | { |
| | | public CreateFeatureTypeStrategy getCreateStrategy() { |
| | | return createStrategy; |
| | | } |
| | | |
| | | public void setCreateStrategy(CreateFeatureTypeStrategy createStrategy) |
| | | { |
| | | if (this.createStrategy != null) |
| | | { |
| | | public void setCreateStrategy(CreateFeatureTypeStrategy createStrategy) { |
| | | if (this.createStrategy != null) { |
| | | this.createStrategy.removeCreateFeatureTypeEventListener(this); |
| | | } |
| | | this.createStrategy = createStrategy; |
| | | |
| | | if (this.createStrategy != null) |
| | | { |
| | | if (this.createStrategy != null) { |
| | | this.createStrategy.addCreateFeatureTypeEventListener(this); |
| | | } |
| | | } |
| | | |
| | | public boolean isDispatchable(Element element) |
| | | { |
| | | public boolean isDispatchable(Element element) { |
| | | FrammeAttributeData featureLinkage = getFeatureLinkage(element); |
| | | return featureLinkage != null && tid == featureLinkage.getFsc() && |
| | | (compareType(element) == 0); |
| | | } |
| | | |
| | | public Feature execute(Element element, boolean useTransform) |
| | | { |
| | | try |
| | | { |
| | | public SimpleFeature execute(Element element, short distId, boolean useTransform) { |
| | | try { |
| | | String ftName = getFeatureTypeName(element); |
| | | FeatureType ftype = createStrategy.createFeatureElement(ftName); |
| | | return createStrategy.createFeature(ftype, element, useTransform); |
| | | } catch (SchemaException e) |
| | | { |
| | | SimpleFeatureType ftype = createStrategy.createFeatureElement(ftName); |
| | | return createStrategy.createFeature(ftype, element, distId, useTransform); |
| | | } catch (SchemaException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | } catch (IllegalAttributeException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public boolean isUseLongName() |
| | | { |
| | | public boolean isUseLongName() { |
| | | return useLongName; |
| | | } |
| | | |
| | | public void setUseLongName(boolean useLongName) |
| | | { |
| | | public void setUseLongName(boolean useLongName) { |
| | | this.useLongName = useLongName; |
| | | } |
| | | |
| | | public String getFeatureTypeName(Element element) |
| | | { |
| | | public String getFeatureTypeName(Element element) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | String name = getName().toLowerCase(); |
| | | String[] pices = StringUtils.splitToArray(name, "."); |
| | | boolean bfirst = true; |
| | | for (String temp : pices) |
| | | { |
| | | for (String temp : pices) { |
| | | if (bfirst) bfirst = false; |
| | | else sb.append('-'); |
| | | sb.append(temp); |
| | | } |
| | | if (useLongName) |
| | | { |
| | | if (useLongName) { |
| | | sb.append("_"); |
| | | sb.append(element.getLevelIndex()); |
| | | sb.append("_"); |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public void createFeatureTypeOccurred(FeatureTypeEvent evt) |
| | | { |
| | | public void createFeatureTypeOccurred(FeatureTypeEvent evt) { |
| | | fireFeatureTypeEvent(evt); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ximple.eofms.geoserver.config; |
| | | |
| | | public class XGeosDataConfig { |
| | | private String PG; |
| | | private short FSC; |
| | | private short COMP; |
| | | private short LEV; |
| | | private short WEIGHT; |
| | | private String FTYPE; |
| | | |
| | | public XGeosDataConfig() { |
| | | } |
| | | |
| | | public String getPG() { |
| | | return PG; |
| | | } |
| | | |
| | | public void setPG(String PG) { |
| | | this.PG = PG; |
| | | } |
| | | |
| | | public short getFSC() { |
| | | return FSC; |
| | | } |
| | | |
| | | public void setFSC(short FSC) { |
| | | this.FSC = FSC; |
| | | } |
| | | |
| | | public short getCOMP() { |
| | | return COMP; |
| | | } |
| | | |
| | | public void setCOMP(short COMP) { |
| | | this.COMP = COMP; |
| | | } |
| | | |
| | | public short getLEV() { |
| | | return LEV; |
| | | } |
| | | |
| | | public void setLEV(short LEV) { |
| | | this.LEV = LEV; |
| | | } |
| | | |
| | | public short getWEIGHT() { |
| | | return WEIGHT; |
| | | } |
| | | |
| | | public void setWEIGHT(short WEIGHT) { |
| | | this.WEIGHT = WEIGHT; |
| | | } |
| | | |
| | | public String getFTYPE() { |
| | | return FTYPE; |
| | | } |
| | | |
| | | public void setFTYPE(String FTYPE) { |
| | | this.FTYPE = FTYPE; |
| | | } |
| | | |
| | | public String toString() { |
| | | return "XGeosDataConfig{" + |
| | | "PG='" + (PG != null ? PG : "null") + '\'' + |
| | | ", FSC=" + FSC + |
| | | ", COMP=" + COMP + |
| | | ", LEV=" + LEV + |
| | | ", WEIGHT=" + WEIGHT + |
| | | ", FTYPE='" + (FTYPE != null ? FTYPE : "null") + '\'' + |
| | | '}'; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ximple.eofms.geoserver.config; |
| | | |
| | | import org.apache.commons.collections.MultiMap; |
| | | import org.apache.commons.collections.map.MultiValueMap; |
| | | |
| | | public class XGeosDataConfigMapping { |
| | | private MultiValueMap mappings; |
| | | |
| | | public XGeosDataConfigMapping() { |
| | | mappings = new MultiValueMap(); |
| | | } |
| | | |
| | | public void addConfig(XGeosDataConfig config) { |
| | | mappings.put(config.getPG(), config); |
| | | } |
| | | |
| | | public MultiMap getMapping() { |
| | | return mappings; |
| | | } |
| | | } |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.nio.BufferOverflowException; |
| | | import java.nio.ByteBuffer; |
| | | import java.sql.Connection; |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | import java.sql.Statement; |
| | | import java.util.ArrayList; |
| | | import java.util.Map; |
| | | import java.util.StringTokenizer; |
| | | import java.util.TreeMap; |
| | | |
| | | import com.vividsolutions.jts.util.Assert; |
| | | import com.ximple.eofms.jobs.context.AbstractOracleJobContext; |
| | | import com.ximple.eofms.util.FeatureTypeBuilderUtil; |
| | | import oracle.sql.BLOB; |
| | | import org.apache.commons.logging.Log; |
| | | import org.geotools.data.DataStore; |
| | | import org.geotools.data.jdbc.ConnectionPoolManager; |
| | | import org.geotools.data.oracle.OracleDataStore; |
| | | import org.geotools.data.oracle.OracleDataStoreFactory; |
| | | import org.geotools.data.oracle.OracleNGDataStoreFactory; |
| | | import org.geotools.jdbc.JDBCDataStore; |
| | | import org.quartz.Job; |
| | | import org.quartz.JobDataMap; |
| | | import org.quartz.JobDetail; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | |
| | | import com.vividsolutions.jts.util.Assert; |
| | | |
| | | import oracle.sql.BLOB; |
| | | |
| | | import com.ximple.eofms.jobs.context.AbstractOracleJobContext; |
| | | |
| | | public abstract class AbstractOracleDatabaseJob implements Job |
| | | { |
| | | public abstract class AbstractOracleDatabaseJob implements Job { |
| | | /** |
| | | * The Oracle driver class name |
| | | */ |
| | |
| | | private static final String CONVERTDB = "CONVERTDB"; |
| | | private static final String CONVERTFILE = "CONVERTFILE"; |
| | | private static final String CONVERTELEMIN = "CONVERTELEMIN"; |
| | | private static final String CONVERTPWTHEMES = "CONVERTPWTHEMES"; |
| | | private static final String CREATEDUMMY = "CREATEDUMMY"; |
| | | private static final String ELEMLOG = "ELEMLOG"; |
| | | private static final String ORAHOST = "ORAHOST"; |
| | |
| | | private static final String TESTMODE = "TESTMODE"; |
| | | private static final String TESTCOUNT = "TESTCOUNT"; |
| | | private static final String COPYCONNECTIVITYMODE = "COPYCONNECTIVITYMODE"; |
| | | private static final String PROFILEMODE = "PROFILEMODE"; |
| | | private static final String USEZONE121 = "USEZONE121"; |
| | | private static final String IGNORE_DBETL = "IGNORE_DBETL"; |
| | | |
| | | protected static OracleDataStoreFactory dataStoreFactory = new OracleDataStoreFactory(); |
| | | protected static OracleNGDataStoreFactory dataStoreFactory = new OracleNGDataStoreFactory(); |
| | | |
| | | protected String _dataPath; |
| | | protected String _filterPath; |
| | |
| | | protected String _convertDB; |
| | | protected String _convertFile; |
| | | protected String _convertElementIn; |
| | | protected String _convertPWThemes; |
| | | protected String _elementLogging; |
| | | protected String _createDummy; |
| | | protected ArrayList<String> _orgSchema = new ArrayList<String>(); |
| | | protected boolean _testMode = false; |
| | | protected boolean _copyConnectivityMode = false; |
| | | protected boolean _profileMode = false; |
| | | protected boolean _useZone121 = true; |
| | | protected boolean _useTransform = true; |
| | | protected boolean _ignoreDBETL = false; |
| | | |
| | | protected int _testCount = -1; |
| | | protected OracleDataStore sourceDataStore; |
| | | protected JDBCDataStore sourceDataStore; |
| | | private boolean driverFound = true; |
| | | |
| | | protected AbstractOracleDatabaseJob() |
| | | { |
| | | try |
| | | { |
| | | private long _processTime; |
| | | private long _updateTime; |
| | | private long _processTimeStart; |
| | | private long _updateTimeStart; |
| | | |
| | | protected AbstractOracleDatabaseJob() { |
| | | try { |
| | | Class.forName(JDBC_DRIVER); |
| | | } catch (Throwable t) |
| | | { |
| | | } catch (Throwable t) { |
| | | // must be running off dummy jar! |
| | | driverFound = false; |
| | | } |
| | |
| | | |
| | | public abstract Log getLogger(); |
| | | |
| | | protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException |
| | | { |
| | | protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException { |
| | | // The directory to scan is stored in the job map |
| | | JobDataMap dataMap = jobDetail.getJobDataMap(); |
| | | _dataPath = dataMap.getString(JOBDATA_DIR); |
| | |
| | | _convertDB = dataMap.getString(CONVERTDB); |
| | | _convertFile = dataMap.getString(CONVERTFILE); |
| | | _convertElementIn = dataMap.getString(CONVERTELEMIN); |
| | | _convertPWThemes = dataMap.getString(CONVERTPWTHEMES); |
| | | _elementLogging = dataMap.getString(ELEMLOG); |
| | | _createDummy = dataMap.getString(CREATEDUMMY); |
| | | |
| | |
| | | |
| | | String strSchema = dataMap.getString(SPATAILSCHEMA); |
| | | StringTokenizer st = new StringTokenizer(strSchema, ","); |
| | | while (st.hasMoreTokens()) |
| | | { |
| | | while (st.hasMoreTokens()) { |
| | | String aSchema = st.nextToken().trim(); |
| | | _orgSchema.add(aSchema); |
| | | } |
| | | _testMode = dataMap.getBooleanFromString(TESTMODE); |
| | | _testCount = dataMap.getIntFromString(TESTCOUNT); |
| | | _copyConnectivityMode = dataMap.getBooleanFromString(COPYCONNECTIVITYMODE); |
| | | _profileMode = dataMap.getBooleanFromString(PROFILEMODE); |
| | | _useZone121 = dataMap.getBooleanFromString(USEZONE121); |
| | | _ignoreDBETL = dataMap.getBooleanFromString(IGNORE_DBETL); |
| | | |
| | | if (_useZone121) { |
| | | FeatureTypeBuilderUtil.setDefaultFeatureSRID(3826); |
| | | } else { |
| | | FeatureTypeBuilderUtil.setDefaultFeatureSRID(3825); |
| | | } |
| | | |
| | | // Validate the required input |
| | | if (_dataPath == null) |
| | | { |
| | | if (logger != null) |
| | | { |
| | | if (_dataPath == null) { |
| | | if (logger != null) { |
| | | logger.warn("Cannot found data directory in configarion."); |
| | | } |
| | | throw new JobExecutionException("Directory not configured"); |
| | |
| | | |
| | | // Make sure the directory exists |
| | | File dir = new File(_dataPath); |
| | | if (!dir.exists()) |
| | | { |
| | | if (!dir.exists()) { |
| | | logger = getLogger(); |
| | | if (logger != null) |
| | | { |
| | | if (logger != null) { |
| | | logger.warn("Cannot found data directory in file system.[" + _dataPath + "]"); |
| | | } |
| | | throw new JobExecutionException("Invalid Dir " + _dataPath); |
| | | } |
| | | |
| | | if (_oracleHost == null) |
| | | { |
| | | if (_oracleHost == null) { |
| | | logger.warn("OracleHOST is null"); |
| | | throw new JobExecutionException("Unknown Oracle Host."); |
| | | } |
| | | if (_oracleInstance == null) |
| | | { |
| | | if (_oracleInstance == null) { |
| | | logger.warn("OracleINSTANCE is null"); |
| | | throw new JobExecutionException("Unknown Oracle Instance."); |
| | | } |
| | | if (_username == null) |
| | | { |
| | | if (_username == null) { |
| | | logger.warn("OracleUSER is null"); |
| | | throw new JobExecutionException("Unknown Oracle Username."); |
| | | } |
| | | if (_password == null) |
| | | { |
| | | if (_password == null) { |
| | | logger.warn("OraclePASS is null"); |
| | | throw new JobExecutionException("Unknown Oracle Password."); |
| | | } |
| | | if (_orgSchema == null) |
| | | { |
| | | if (_orgSchema == null) { |
| | | logger.warn("OracleSchema is null"); |
| | | throw new JobExecutionException("Unknown Spatial Database Schema."); |
| | | } |
| | | } |
| | | |
| | | protected abstract AbstractOracleJobContext prepareJobContext(String targetSchemaName, String filterPath); |
| | | protected abstract AbstractOracleJobContext prepareJobContext(String targetSchemaName, String filterPath, |
| | | boolean profileMode, boolean useTransform); |
| | | |
| | | protected static byte[] getBytesFromBLOB(BLOB blob) throws SQLException |
| | | { |
| | | protected byte[] getBytesFromBLOB(BLOB blob) throws SQLException, BufferOverflowException { |
| | | byte[] raw = null; |
| | | |
| | | // BLOB blob = (BLOB) rs.getBlob(1); |
| | |
| | | byte[] chunk = new byte[optimalSize]; |
| | | InputStream is = blob.getBinaryStream(0); |
| | | ByteBuffer buffer = null; // ByteBuffer.allocate(optimalSize); |
| | | int len; |
| | | int len = 0; |
| | | |
| | | try |
| | | { |
| | | while ((len = (is.read(chunk))) != -1) |
| | | { |
| | | if (buffer != null) |
| | | { |
| | | try { |
| | | while ((len = (is.read(chunk))) != -1) { |
| | | if (buffer != null) { |
| | | buffer.limit(buffer.limit() + len); |
| | | } else |
| | | { |
| | | } else { |
| | | buffer = ByteBuffer.allocate(len); |
| | | } |
| | | |
| | | buffer.put(chunk); |
| | | buffer.put(chunk, 0, len); |
| | | } |
| | | |
| | | is.close(); |
| | | |
| | | assert buffer != null; |
| | | buffer.position(0); |
| | | raw = buffer.array(); |
| | | } catch (IOException e) |
| | | { |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. |
| | | Assert.shouldNeverReachHere(); |
| | | } catch (BufferOverflowException e) { |
| | | getLogger().warn("BufferOverflowException:: len = " + len + "buffer.limit=" + buffer.limit()); |
| | | } finally { |
| | | try { |
| | | is.close(); |
| | | } catch (IOException e) { |
| | | getLogger().warn("InputStream cannot close", e); |
| | | } |
| | | ; |
| | | } |
| | | |
| | | return raw; |
| | | } |
| | | |
| | | public boolean isDriverFound() |
| | | { |
| | | public boolean isDriverFound() { |
| | | return driverFound; |
| | | } |
| | | |
| | | public String getDataPath() |
| | | { |
| | | public String getDataPath() { |
| | | return _dataPath; |
| | | } |
| | | |
| | | public String getFilterPath() |
| | | { |
| | | public String getFilterPath() { |
| | | return _filterPath; |
| | | } |
| | | |
| | | public String getOracleHost() |
| | | { |
| | | public String getOracleHost() { |
| | | return _oracleHost; |
| | | } |
| | | |
| | | public String getOracleInstance() |
| | | { |
| | | public String getOracleInstance() { |
| | | return _oracleInstance; |
| | | } |
| | | |
| | | public String getOraclePort() |
| | | { |
| | | public String getOraclePort() { |
| | | return _oraclePort; |
| | | } |
| | | |
| | | public String getUsername() |
| | | { |
| | | public String getUsername() { |
| | | return _username; |
| | | } |
| | | |
| | | public String getPassword() |
| | | { |
| | | public String getPassword() { |
| | | return _password; |
| | | } |
| | | |
| | | public ArrayList<String> getOriginSchema() |
| | | { |
| | | public ArrayList<String> getOriginSchema() { |
| | | return _orgSchema; |
| | | } |
| | | |
| | | public boolean isTestMode() |
| | | { |
| | | public boolean isTestMode() { |
| | | return _testMode; |
| | | } |
| | | |
| | | public int getTestCount() |
| | | { |
| | | public int getTestCount() { |
| | | return _testCount; |
| | | } |
| | | |
| | | public String getConvertDB() |
| | | { |
| | | public String getConvertDB() { |
| | | return _convertDB; |
| | | } |
| | | |
| | | public void setConvertDB(String convertDB) |
| | | { |
| | | public void setConvertDB(String convertDB) { |
| | | _convertDB = convertDB; |
| | | } |
| | | |
| | | public String getConvertFile() |
| | | { |
| | | public String getConvertFile() { |
| | | return _convertFile; |
| | | } |
| | | |
| | | public void setConvertFile(String convertFile) |
| | | { |
| | | public void setConvertFile(String convertFile) { |
| | | _convertFile = convertFile; |
| | | } |
| | | |
| | | public String getConvertElementIn() |
| | | { |
| | | public String getConvertElementIn() { |
| | | return _convertElementIn; |
| | | } |
| | | |
| | | public void setConvertElementIn(String convertElementIn) |
| | | { |
| | | public void setConvertElementIn(String convertElementIn) { |
| | | _convertElementIn = convertElementIn; |
| | | } |
| | | |
| | | public boolean checkConvertDB() |
| | | { |
| | | public boolean checkConvertDB() { |
| | | return _convertDB != null && !_convertDB.equalsIgnoreCase("false") && |
| | | !_convertDB.equalsIgnoreCase("no") && !_convertDB.equalsIgnoreCase("0"); |
| | | } |
| | | |
| | | public boolean checkConvertFile() |
| | | { |
| | | public boolean checkConvertFile() { |
| | | return _convertFile != null && !_convertFile.equalsIgnoreCase("false") && |
| | | !_convertFile.equalsIgnoreCase("no") && !_convertFile.equalsIgnoreCase("0"); |
| | | } |
| | | |
| | | public boolean checkConvertElementIn() |
| | | { |
| | | public boolean checkConvertElementIn() { |
| | | return _convertElementIn != null && !_convertElementIn.equalsIgnoreCase("false") && |
| | | !_convertElementIn.equalsIgnoreCase("no") && !_convertElementIn.equalsIgnoreCase("0"); |
| | | } |
| | | |
| | | public String getElementLogging() |
| | | { |
| | | public boolean checkConvertPWThemes() { |
| | | return _convertPWThemes != null && !_convertPWThemes.equalsIgnoreCase("false") && |
| | | !_convertPWThemes.equalsIgnoreCase("no") && !_convertPWThemes.equalsIgnoreCase("0"); |
| | | } |
| | | |
| | | public String getElementLogging() { |
| | | return _elementLogging; |
| | | } |
| | | |
| | | public void setElementLogging(String elementLogging) |
| | | { |
| | | public void setElementLogging(String elementLogging) { |
| | | this._elementLogging = elementLogging; |
| | | } |
| | | |
| | | public boolean checkElementLogging() |
| | | { |
| | | public boolean checkElementLogging() { |
| | | return _elementLogging != null && !_elementLogging.equalsIgnoreCase("false") && |
| | | !_elementLogging.equalsIgnoreCase("no") && !_elementLogging.equalsIgnoreCase("0"); |
| | | } |
| | | |
| | | public boolean checkCreateDummy() |
| | | { |
| | | public boolean checkCreateDummy() { |
| | | return _createDummy != null && !_createDummy.equalsIgnoreCase("false") && |
| | | !_createDummy.equalsIgnoreCase("no") && !_createDummy.equalsIgnoreCase("0"); |
| | | } |
| | | |
| | | public boolean isCopyConnectivityMode() |
| | | { |
| | | public boolean isCopyConnectivityMode() { |
| | | return _copyConnectivityMode; |
| | | } |
| | | |
| | | public DataStore getSourceDataStore() |
| | | { |
| | | public boolean isProfileMode() { |
| | | return _profileMode; |
| | | } |
| | | |
| | | public boolean isTransformed() { |
| | | return _useTransform; |
| | | } |
| | | |
| | | public boolean isZone121() { |
| | | return _useZone121; |
| | | } |
| | | |
| | | public boolean isIgnoreDBETL() { |
| | | return _ignoreDBETL; |
| | | } |
| | | |
| | | public void set_ignoreDBETL(boolean _ignoreDBETL) { |
| | | this._ignoreDBETL = _ignoreDBETL; |
| | | } |
| | | |
| | | public DataStore getSourceDataStore() { |
| | | return sourceDataStore; |
| | | } |
| | | |
| | | protected void createSourceDataStore() throws JobExecutionException |
| | | { |
| | | if (sourceDataStore != null) |
| | | { |
| | | protected void createSourceDataStore() throws JobExecutionException { |
| | | if (sourceDataStore != null) { |
| | | sourceDataStore.dispose(); |
| | | sourceDataStore = null; |
| | | } |
| | | |
| | | if (!isDriverFound()) |
| | | { |
| | | if (!isDriverFound()) { |
| | | throw new JobExecutionException("Oracle JDBC Driver not found.-" + JDBC_DRIVER); |
| | | } |
| | | Map<String, String> map = new TreeMap<String, String>(); |
| | | map.put("host", _oracleHost); |
| | | map.put("port", _oraclePort); |
| | | map.put("instance", _oracleInstance); |
| | | map.put("user", _username); |
| | | map.put("passwd", _password); |
| | | map.put("dbtype", "oracle"); |
| | | map.put("alias", _oracleInstance); |
| | | map.put("namespace", null); |
| | | if (!map.containsKey(OracleDataStoreFactory.MAXCONN.key)) |
| | | { |
| | | map.put(OracleDataStoreFactory.MAXCONN.key, "10"); |
| | | map.put(OracleNGDataStoreFactory.HOST.key, _oracleHost); |
| | | map.put(OracleNGDataStoreFactory.PORT.key, _oraclePort); |
| | | map.put(OracleNGDataStoreFactory.DATABASE.key, _oracleInstance); |
| | | map.put(OracleNGDataStoreFactory.USER.key, _username); |
| | | map.put(OracleNGDataStoreFactory.PASSWD.key, _password); |
| | | map.put(OracleNGDataStoreFactory.DBTYPE.key, "oracle"); |
| | | map.put(OracleNGDataStoreFactory.NAMESPACE.key, null); |
| | | |
| | | if (!map.containsKey(OracleNGDataStoreFactory.MAXCONN.key)) { |
| | | map.put(OracleNGDataStoreFactory.MAXCONN.key, "5"); |
| | | } |
| | | if (!map.containsKey(OracleDataStoreFactory.MINCONN.key)) |
| | | { |
| | | map.put(OracleDataStoreFactory.MINCONN.key, "1"); |
| | | if (!map.containsKey(OracleNGDataStoreFactory.MINCONN.key)) { |
| | | map.put(OracleNGDataStoreFactory.MINCONN.key, "1"); |
| | | } |
| | | |
| | | if (!dataStoreFactory.canProcess(map)) |
| | | { |
| | | if (!dataStoreFactory.canProcess(map)) { |
| | | getLogger().warn("cannot process properties-"); |
| | | throw new JobExecutionException("cannot process properties-"); |
| | | } |
| | | try |
| | | { |
| | | sourceDataStore = (OracleDataStore) dataStoreFactory.createDataStore(map); |
| | | } catch (IOException e) |
| | | { |
| | | try { |
| | | sourceDataStore = dataStoreFactory.createDataStore(map); |
| | | } catch (IOException e) { |
| | | getLogger().warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | protected void disconnect() |
| | | { |
| | | ConnectionPoolManager manager = ConnectionPoolManager.getInstance(); |
| | | manager.closeAll(); |
| | | protected void disconnect() { |
| | | // ConnectionPoolManager manager = ConnectionPoolManager.getInstance(); |
| | | // manager.closeAll(); |
| | | if (sourceDataStore != null) { |
| | | sourceDataStore.dispose(); |
| | | sourceDataStore = null; |
| | | } |
| | | } |
| | | |
| | | public final void accumulateProcessTime() { |
| | | _processTime += System.currentTimeMillis() - _processTimeStart; |
| | | } |
| | | |
| | | public final void accumulateUpdateTime() { |
| | | _updateTime += System.currentTimeMillis() - _updateTimeStart; |
| | | } |
| | | |
| | | public long getProcessTime() { |
| | | return _processTime; |
| | | } |
| | | |
| | | public long getUpdateTime() { |
| | | return _updateTime; |
| | | } |
| | | |
| | | public final void markProcessTime() { |
| | | _processTimeStart = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public final void markUpdateTime() { |
| | | _updateTimeStart = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public final void resetProcessTime() { |
| | | _processTime = 0; |
| | | } |
| | | |
| | | public final void resetUpdateTime() { |
| | | _updateTime = 0; |
| | | } |
| | | |
| | | /** |
| | | * Connectivity (Connectivity) |
| | | * |
| | | * @param jobContext job context |
| | | * @throws java.sql.SQLException sql exception |
| | | */ |
| | | protected void copyConnectivity(AbstractOracleJobContext jobContext) throws SQLException { |
| | | Connection connection = jobContext.getOracleConnection(); |
| | | ResultSet rsMeta = connection.getMetaData().getTables(null, "BASEDB", |
| | | AbstractOracleJobContext.CONNECTIVITY_WEBCHECK_NAME + "%", |
| | | new String[]{"TABLE"}); |
| | | |
| | | boolean found = false; |
| | | try { |
| | | while (rsMeta.next()) { |
| | | String tablename = rsMeta.getString(3); |
| | | if (AbstractOracleJobContext.CONNECTIVITY_WEBCHECK_NAME.equalsIgnoreCase(tablename)) { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | // } catch (SQLException e) |
| | | } finally { |
| | | if (rsMeta != null) { |
| | | rsMeta.close(); |
| | | rsMeta = null; |
| | | } |
| | | } |
| | | Statement stmt = connection.createStatement(); |
| | | if (found) { |
| | | stmt.execute(AbstractOracleJobContext.TRUNCATE_CONNECTIVITY_WEBCHECK); |
| | | } else { |
| | | getLogger().info("Create CONNECTIVITY_WEBCHECK table."); |
| | | stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK); |
| | | stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_1); |
| | | stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_2); |
| | | stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_3); |
| | | stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_4); |
| | | stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_5); |
| | | stmt.execute(AbstractOracleJobContext.CREATE_CONNECTIVITY_WEBCHECK_INDEX_6); |
| | | stmt.execute(AbstractOracleJobContext.ALTER_CONNECTIVITY_WEBCHECK_1); |
| | | stmt.execute(AbstractOracleJobContext.ALTER_CONNECTIVITY_WEBCHECK_2); |
| | | } |
| | | |
| | | stmt.execute(AbstractOracleJobContext.COPY_CONNECTIVITY_TO_WEBCHECK); |
| | | stmt.close(); |
| | | } |
| | | |
| | | protected void fetchTPData(AbstractOracleJobContext jobContext) { |
| | | Connection connection = jobContext.getOracleConnection(); |
| | | |
| | | try { |
| | | Statement stmt = connection.createStatement(); |
| | | ResultSet rs = stmt.executeQuery(AbstractOracleJobContext.FETCH_TPDATA); |
| | | if (rs.next()) { |
| | | short disId = rs.getShort(1); |
| | | jobContext.setDistId(disId); |
| | | |
| | | String distName = rs.getString(2); |
| | | jobContext.setDistName(distName); |
| | | } |
| | | rs.close(); |
| | | stmt.close(); |
| | | } catch (SQLException e) { |
| | | getLogger().warn("Fetch TPDATA Error.", e); |
| | | } |
| | | } |
| | | |
| | | protected void createHibernateSequence(AbstractOracleJobContext jobContext) throws SQLException { |
| | | Connection connection = jobContext.getOracleConnection(); |
| | | |
| | | try { |
| | | Statement stmt = connection.createStatement(); |
| | | stmt.execute(AbstractOracleJobContext.CREATE_HIBERNATE_SEQUENCE); |
| | | stmt.close(); |
| | | } catch (SQLException e) { |
| | | getLogger().warn("HIBERNATE_SEQUENCE is already exist."); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ximple.eofms.jobs; |
| | | |
| | | public interface DataReposVersionManager |
| | | { |
| | | public interface DataReposVersionManager { |
| | | public static final String XGVERSIONTABLE_NAME = "xgeos_vsversion"; |
| | | public static final String[] DEFAULTXGVERSIONSCHEMA_NAMES = new String[] { |
| | | "gisrepo1", "gisrepo2" |
| | | }; |
| | | |
| | | public static final String XPTVERSIONTABLE_NAME = "xpwthemes_vsversion"; |
| | | public static final String[] DEFAULTXPTVERSIONTABLE_NAMES = new String[]{ |
| | | "xpwtheme1", "xpwtheme2" |
| | | }; |
| | | |
| | | public static final short VSSTATUS_AVAILABLE= 0x0000; |
| | | public static final short VSSTATUS_USING = 0x0100; |
| | | public static final short VSSTATUS_CONFIG = 0x0020; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | import org.apache.commons.digester.Digester; |
| | | import org.apache.commons.digester.xmlrules.DigesterLoader; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.apache.commons.transaction.memory.PessimisticMapWrapper; |
| | | import org.apache.commons.transaction.util.CommonsLoggingLogger; |
| | | import org.apache.commons.transaction.util.LoggerFacade; |
| | | import org.geotools.data.FeatureWriter; |
| | | import org.geotools.data.Transaction; |
| | | import org.geotools.data.shapefile.ShapefileDataStore; |
| | | import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.feature.SimpleFeature; |
| | | import org.xml.sax.SAXException; |
| | | |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import java.util.TimeZone; |
| | | |
| | | import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; |
| | | import com.ximple.eofms.filter.ElementDispatchableFilter; |
| | |
| | | import com.ximple.eofms.filter.TypeCompLevelIdDispatchableFilter; |
| | | import com.ximple.eofms.filter.TypeIdDispatchableFilter; |
| | | import com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; |
| | | import com.ximple.eofms.util.ElementDigesterUtils; |
| | | import com.ximple.io.dgn7.ComplexElement; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | import com.ximple.io.dgn7.UserAttributeData; |
| | | import org.apache.commons.digester3.Digester; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.apache.commons.transaction.memory.PessimisticMapWrapper; |
| | | import org.apache.commons.transaction.util.CommonsLoggingLogger; |
| | | import org.apache.commons.transaction.util.LoggerFacade; |
| | | import org.geotools.data.FeatureWriter; |
| | | import org.geotools.data.Transaction; |
| | | import org.geotools.data.shapefile.ShapefileDataStore; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.opengis.feature.simple.SimpleFeature; |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | import org.xml.sax.SAXException; |
| | | |
| | | public class DummyFeatureConvertJobContext extends AbstractDgnFileJobContext |
| | | { |
| | | public class DummyFeatureConvertJobContext extends AbstractDgnFileJobContext { |
| | | static final Log logger = LogFactory.getLog(DummyFeatureConvertJobContext.class); |
| | | static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); |
| | | static final GeometryFactory geometryFactory = new GeometryFactory(); |
| | | static final String SHPOUTPATH = "shpout"; |
| | | |
| | | private String dataOut = null; |
| | | |
| | | private HashMap<String, ArrayList<Feature>> featuresContext = new HashMap<String, ArrayList<Feature>>(); |
| | | private HashMap<String, ArrayList<SimpleFeature>> featuresContext = new HashMap<String, ArrayList<SimpleFeature>>(); |
| | | private HashMap<String, FeatureWriter> featuresWriterContext = new HashMap<String, FeatureWriter>(); |
| | | |
| | | private PessimisticMapWrapper txFeaturesContext; |
| | |
| | | private ElementDispatcher elementDispatcher; |
| | | private String _filterConfig; |
| | | |
| | | public DummyFeatureConvertJobContext(String dataPath, String filterConfig) |
| | | { |
| | | super(dataPath); |
| | | public DummyFeatureConvertJobContext(String dataPath, String filterConfig, boolean profileMode, |
| | | boolean useTransform) { |
| | | super(dataPath, profileMode, useTransform); |
| | | txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); |
| | | _filterConfig = filterConfig; |
| | | elementDispatcher = createElementDispatcher(); |
| | | } |
| | | |
| | | private ElementDispatcher createElementDispatcher() |
| | | { |
| | | try |
| | | { |
| | | URL rulesURL = ElementDispatcher.class.getResource("ElementDispatcherRules.xml"); |
| | | assert rulesURL != null; |
| | | Digester digester = DigesterLoader.createDigester(rulesURL); |
| | | private ElementDispatcher createElementDispatcher() { |
| | | try { |
| | | URL filterURL = null; |
| | | if (_filterConfig != null) |
| | | { |
| | | if (_filterConfig != null) { |
| | | File config = new File(_filterConfig); |
| | | if (config.exists()) |
| | | { |
| | | if (config.exists()) { |
| | | filterURL = config.toURI().toURL(); |
| | | } |
| | | } |
| | | if (filterURL == null) |
| | | { |
| | | if (filterURL == null) { |
| | | // config = new File("conf/DefaultConvertShpFilter.xml"); |
| | | filterURL = this.getClass().getResource("/conf/DefaultConvertShpFilter.xml"); |
| | | // filterURL = this.getClass().getResource("/conf/ConvertShpFilterForLevel.xml"); |
| | | } |
| | | assert filterURL != null; |
| | | Digester digester = ElementDigesterUtils.getElementDigester(); |
| | | return (ElementDispatcher) digester.parse(filterURL); |
| | | } catch (UnsupportedEncodingException e) |
| | | { |
| | | } catch (UnsupportedEncodingException e) { |
| | | logger.info(e.getMessage(), e); |
| | | throw new RuntimeException(e.getMessage(), e); |
| | | } catch (MalformedURLException e) |
| | | { |
| | | } catch (MalformedURLException e) { |
| | | logger.info(e.getMessage(), e); |
| | | throw new RuntimeException(e.getMessage(), e); |
| | | } catch (IOException e) |
| | | { |
| | | } catch (IOException e) { |
| | | logger.info(e.getMessage(), e); |
| | | throw new RuntimeException(e.getMessage(), e); |
| | | } catch (SAXException e) |
| | | { |
| | | } catch (SAXException e) { |
| | | logger.info(e.getMessage(), e); |
| | | throw new RuntimeException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException |
| | | { |
| | | public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException { |
| | | assert elementDispatcher != null; |
| | | |
| | | if (element == null) |
| | | { |
| | | if (element == null) { |
| | | logger.warn("Unknown Element:" + null); |
| | | return; |
| | | } |
| | | |
| | | // §PÂ_¬O§_²Å©M±ø¥ó |
| | | Feature feature = elementDispatcher.execute(element, true); |
| | | if (feature == null) |
| | | { |
| | | SimpleFeature feature = elementDispatcher.execute(element, getDistId(), isTransformed()); |
| | | if (feature == null) { |
| | | FrammeAttributeData linkage = |
| | | AbstractFLinkageDispatchableFilter.getFeatureLinkage(element); |
| | | logger.warn("Unknown Element:" + element.getElementType().toString() + |
| | | ":type=" + element.getType() + ":lv=" + element.getLevelIndex() + ":id=" + |
| | | (linkage == null ? "NULL" : (linkage.getFsc() + "|" + linkage.getComponentID()))); |
| | | if (element instanceof ComplexElement) |
| | | { |
| | | (linkage == null ? "NULL" : "FSC=" + (linkage.getFsc() + "|COMPID=" + linkage.getComponentID()))); |
| | | if (element instanceof ComplexElement) { |
| | | ComplexElement complex = (ComplexElement) element; |
| | | logger.warn("----Complex Element size=" + complex.size()); |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!txFeaturesContext.containsKey(feature.getFeatureType())) |
| | | { |
| | | if (!txFeaturesContext.containsKey(feature.getFeatureType())) { |
| | | txFeaturesContext.put(feature.getFeatureType(), new ArrayList()); |
| | | } |
| | | ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType()); |
| | | arrayList.add(feature); |
| | | } |
| | | |
| | | public void startTransaction() |
| | | { |
| | | public void startTransaction() { |
| | | assert elementDispatcher != null; |
| | | for (ElementDispatchableFilter filter : elementDispatcher.getRules()) |
| | | { |
| | | if (filter instanceof TypeCompIdDispatchableFilter) |
| | | { |
| | | for (ElementDispatchableFilter filter : elementDispatcher.getRules()) { |
| | | if (filter instanceof TypeCompIdDispatchableFilter) { |
| | | ((TypeCompIdDispatchableFilter) filter).getCreateStrategy(); |
| | | } else if (filter instanceof TypeCompLevelIdDispatchableFilter) |
| | | { |
| | | } else if (filter instanceof TypeCompLevelIdDispatchableFilter) { |
| | | ((TypeCompIdDispatchableFilter) filter).getCreateStrategy(); |
| | | } else if (filter instanceof TypeIdDispatchableFilter) |
| | | { |
| | | } else if (filter instanceof TypeIdDispatchableFilter) { |
| | | ((TypeCompIdDispatchableFilter) filter).getCreateStrategy(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void commitTransaction() |
| | | { |
| | | if (!txFeaturesContext.isEmpty()) |
| | | { |
| | | public void commitTransaction() { |
| | | if (!txFeaturesContext.isEmpty()) { |
| | | logger.debug("Transaction size = " + txFeaturesContext.size()); |
| | | //txFeaturesContext.commitTransaction(); |
| | | } else |
| | | { |
| | | } else { |
| | | logger.debug("Transaction is empty."); |
| | | } |
| | | |
| | | if (!featuresContext.isEmpty()) |
| | | { |
| | | if (!featuresContext.isEmpty()) { |
| | | updateDataStore(); |
| | | } |
| | | } |
| | | |
| | | public void rollbackTransaction() |
| | | { |
| | | public void rollbackTransaction() { |
| | | //txFeaturesContext.rollbackTransaction(); |
| | | if (!featuresContext.isEmpty()) |
| | | { |
| | | if (!featuresContext.isEmpty()) { |
| | | updateDataStore(); |
| | | } |
| | | } |
| | | |
| | | private void updateDataStore() |
| | | { |
| | | private void updateDataStore() { |
| | | if (isProfileMode()) markUpdateTime(); |
| | | Iterator it = featuresContext.keySet().iterator(); |
| | | |
| | | try |
| | | { |
| | | while (it.hasNext()) |
| | | { |
| | | FeatureType featureType = (FeatureType) it.next(); |
| | | try { |
| | | while (it.hasNext()) { |
| | | SimpleFeatureType featureType = (SimpleFeatureType) it.next(); |
| | | File sfile = new File(getDataOutPath() + File.separator + featureType.getTypeName()); |
| | | logger.debug("Begin Save shapefile:" + sfile.toURI()); |
| | | |
| | | FeatureWriter writer; |
| | | if (featuresWriterContext.containsKey(featureType.getTypeName())) |
| | | { |
| | | if (featuresWriterContext.containsKey(featureType.getTypeName())) { |
| | | writer = featuresWriterContext.get(featureType.getTypeName()); |
| | | } else |
| | | { |
| | | } else { |
| | | // ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL()); |
| | | /* |
| | | ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL(), |
| | | true, Charset.forName("UTF-8")); |
| | | */ |
| | | if (!sfile.exists()) |
| | | { |
| | | ShapefileDataStore shapefileDataStore = new IndexedShapefileDataStore(sfile.toURI().toURL(), |
| | | null, true, true, IndexedShapefileDataStore.TREE_QIX, Charset.forName("UTF-8")); |
| | | ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL()); |
| | | /* |
| | | if(namespace != null) { |
| | | shapefileDataStore.setNamespaceURI(namespace.toString()); |
| | | } |
| | | */ |
| | | shapefileDataStore.setMemoryMapped(true); |
| | | // shapefileDataStore.setBufferCachingEnabled(cacheMemoryMaps); |
| | | shapefileDataStore.setCharset(Charset.forName("UTF-8")); |
| | | shapefileDataStore.setTimeZone(TimeZone.getDefault()); |
| | | shapefileDataStore.setIndexed(true); |
| | | shapefileDataStore.setIndexCreationEnabled(true); |
| | | |
| | | if (!sfile.exists()) { |
| | | shapefileDataStore.createSchema(featureType); |
| | | writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), |
| | | Transaction.AUTO_COMMIT); |
| | | } else |
| | | { |
| | | ShapefileDataStore shapefileDataStore = new IndexedShapefileDataStore(sfile.toURI().toURL(), |
| | | null, true, true, IndexedShapefileDataStore.TREE_QIX, Charset.forName("UTF-8")); |
| | | } else { |
| | | writer = shapefileDataStore.getFeatureWriterAppend(featureType.getTypeName(), |
| | | Transaction.AUTO_COMMIT); |
| | | } |
| | | featuresWriterContext.put(featureType.getTypeName(), writer); |
| | | } |
| | | |
| | | ArrayList<Feature> features = featuresContext.get(featureType); |
| | | ArrayList<SimpleFeature> features = featuresContext.get(featureType); |
| | | Iterator itFeature = features.iterator(); |
| | | while (itFeature.hasNext()) |
| | | { |
| | | Feature feature = (Feature) itFeature.next(); |
| | | ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null)); |
| | | while (itFeature.hasNext()) { |
| | | SimpleFeature feature = (SimpleFeature) itFeature.next(); |
| | | ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes()); |
| | | } |
| | | //writer.close(); |
| | | logger.debug("End Save shapefile:" + sfile.toURI()); |
| | | } |
| | | featuresContext.clear(); |
| | | } catch (MalformedURLException e) |
| | | { |
| | | } catch (MalformedURLException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | } catch (IllegalAttributeException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (IOException e) |
| | | { |
| | | } catch (IOException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } finally { |
| | | if (isProfileMode()) accumulateUpdateTime(); |
| | | } |
| | | } |
| | | |
| | | public String getDataOutPath() |
| | | { |
| | | if (dataOut == null) |
| | | { |
| | | public String getDataOutPath() { |
| | | if (dataOut == null) { |
| | | File outPath = new File(getDataPath(), SHPOUTPATH); |
| | | if (!outPath.exists()) |
| | | { |
| | | if (!outPath.exists()) { |
| | | outPath.mkdir(); |
| | | } else if (!outPath.isDirectory()) |
| | | { |
| | | } else if (!outPath.isDirectory()) { |
| | | outPath.mkdir(); |
| | | } |
| | | dataOut = outPath.toString(); |
| | |
| | | return dataOut; |
| | | } |
| | | |
| | | public void closeFeatureWriter() throws IOException |
| | | { |
| | | public void closeFeatureWriter() throws IOException { |
| | | |
| | | for (FeatureWriter featureWriter : this.featuresWriterContext.values()) |
| | | { |
| | | for (FeatureWriter featureWriter : this.featuresWriterContext.values()) { |
| | | featureWriter.close(); |
| | | } |
| | | |
| | | this.featuresWriterContext.clear(); |
| | | } |
| | | |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) |
| | | { |
| | | protected FrammeAttributeData getFeatureLinkage(Element element) { |
| | | if (!element.hasUserAttributeData()) |
| | | return null; |
| | | |
| | | List<UserAttributeData> usrDatas = element.getUserAttributeData(); |
| | | for (UserAttributeData anUsrData : usrDatas) |
| | | { |
| | | if (anUsrData instanceof FrammeAttributeData) |
| | | { |
| | | for (UserAttributeData anUsrData : usrDatas) { |
| | | if (anUsrData instanceof FrammeAttributeData) { |
| | | return (FrammeAttributeData) anUsrData; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public Log getLogger() |
| | | { |
| | | public Log getLogger() { |
| | | return logger; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ximple.eofms.jobs; |
| | | |
| | | import com.vividsolutions.jts.geom.*; |
| | | import com.ximple.eofms.geoserver.config.XGeosDataConfig; |
| | | import com.ximple.eofms.geoserver.config.XGeosDataConfigMapping; |
| | | import com.ximple.eofms.jobs.context.AbstractOracleJobContext; |
| | | import com.ximple.eofms.util.PrintfFormat; |
| | | import com.ximple.eofms.util.XGeosConfigDigesterUtils; |
| | | import it.geosolutions.geoserver.rest.GeoServerRESTManager; |
| | | import it.geosolutions.geoserver.rest.GeoServerRESTPublisher; |
| | | import it.geosolutions.geoserver.rest.GeoServerRESTReader; |
| | | import it.geosolutions.geoserver.rest.decoder.*; |
| | | import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder; |
| | | import it.geosolutions.geoserver.rest.encoder.GSLayerGroupEncoder; |
| | | import it.geosolutions.geoserver.rest.encoder.GSLayerGroupEncoder23; |
| | | import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder; |
| | | import it.geosolutions.geoserver.rest.encoder.datastore.GSPostGISDatastoreEncoder; |
| | | import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder; |
| | | import it.geosolutions.geoserver.rest.manager.GeoServerRESTStoreManager; |
| | | import org.apache.commons.collections.MultiMap; |
| | | import org.apache.commons.digester3.Digester; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.data.Transaction; |
| | | import org.geotools.data.jdbc.JDBCUtils; |
| | | import org.geotools.geometry.GeneralEnvelope; |
| | | import org.jdom.Element; |
| | | import org.opengis.feature.type.FeatureType; |
| | | import org.opengis.feature.type.GeometryDescriptor; |
| | | import org.quartz.JobDataMap; |
| | | import org.quartz.JobDetail; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | import org.xml.sax.SAXException; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.URI; |
| | | import java.net.URISyntaxException; |
| | | import java.net.URL; |
| | | import java.sql.*; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | |
| | | public class GeoserverIntegrateConfigJob extends OracleConvertDgn2PostGISJob { |
| | | final static Log logger = LogFactory.getLog(GeoserverIntegrateConfigJob.class); |
| | | |
| | | private static final String SKIPCONFIGJOB = "SKIPCONFIGJOB"; |
| | | private static final String MASTERMODE = "MASTERMODE"; |
| | | private static final String EPSG = "EPSG:"; |
| | | private static final String DEFAULT_NAMESPACE = "xtpc"; |
| | | private static final String XGEOSDATACONFIG_PATH = "xgeosdataconfig.xml"; |
| | | private static final String GEOSERVER_BASEURL = "GEOSERVER_URL"; |
| | | private static final String GEOSERVER_USER = "GEOSERVER_USER"; |
| | | private static final String GEOSERVER_PASS = "GEOSERVER_PASS"; |
| | | |
| | | // private static final int MAGIC_BLOCKSIZE = (64 * 1024 * 1024) - (32 * 1024); |
| | | |
| | | private static final String QUERY_VIEWDEFSQL = "SELECT table_name, view_definition FROM information_schema.views " + |
| | | "WHERE table_schema = ? AND table_name LIKE "; |
| | | |
| | | private static final String CREATE_VIEWSQL = "CREATE OR REPLACE VIEW \"%s\" AS SELECT * FROM \"%s\".\"%s\""; |
| | | private static final String EXTRAWHERE_VIEWSQL = " WHERE \"%s\".level = %s AND \"%s\".symweight = %s"; |
| | | |
| | | private static final String ALTER_VIEWSQL = "ALTER TABLE \"%s\" OWNER TO "; |
| | | // private static final String GRANT_VIEWSQL = "GRANT SELECT ON TABLE \"%s\" TO public"; |
| | | private static final int SRSID_TWD97_ZONE119 = 3825; |
| | | private static final int SRSID_TWD97_ZONE121 = 3826; |
| | | public static final String DEFAULT_STORENAME = "pgDMMS"; |
| | | public static final String DEFAULT_GEODMMS_NAMESPACE = "http://tpc.ximple.com.tw/geodmms"; |
| | | |
| | | private static XGeosDataConfigMapping xgeosDataConfigMapping = null; |
| | | |
| | | protected String _geoServerURL; |
| | | protected String _geoServerUser; |
| | | protected String _geoServerPass; |
| | | |
| | | private long queryTime = 0; |
| | | private long queryTimeStart = 0; |
| | | |
| | | public Log getLogger() { |
| | | return logger; |
| | | } |
| | | |
| | | protected AbstractOracleJobContext prepareJobContext(String targetSchemaName, String filterPath, |
| | | boolean profileMode, |
| | | boolean useTransform) { |
| | | return super.prepareJobContext(targetSchemaName, filterPath, profileMode, useTransform); |
| | | } |
| | | |
| | | protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException { |
| | | super.extractJobConfiguration(jobDetail); |
| | | |
| | | JobDataMap dataMap = jobDetail.getJobDataMap(); |
| | | _geoServerURL = dataMap.getString(GEOSERVER_BASEURL); |
| | | _geoServerUser = dataMap.getString(GEOSERVER_USER); |
| | | _geoServerPass = dataMap.getString(GEOSERVER_PASS); |
| | | |
| | | if (_geoServerURL == null) { |
| | | logger.warn("GEOSERVER_URL is null"); |
| | | throw new JobExecutionException("Unknown GEOSERVER_URL."); |
| | | } |
| | | if (_geoServerUser == null) { |
| | | logger.warn("GEOSERVER_USER is null"); |
| | | throw new JobExecutionException("Unknown GEOSERVER_USER."); |
| | | } |
| | | if (_geoServerPass == null) { |
| | | logger.warn("GEOSERVER_PASS is null"); |
| | | throw new JobExecutionException("Unknown GEOSERVER_PASS."); |
| | | } |
| | | } |
| | | |
| | | protected XGeosDataConfigMapping getConfigMapping() { |
| | | if (xgeosDataConfigMapping == null) { |
| | | Digester digester = XGeosConfigDigesterUtils.getXGeosConfigDigester(); |
| | | final URL configDataURL = XGeosDataConfigMapping.class.getResource(XGEOSDATACONFIG_PATH); |
| | | try { |
| | | xgeosDataConfigMapping = (XGeosDataConfigMapping) digester.parse(configDataURL); |
| | | } catch (IOException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } catch (SAXException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | |
| | | } |
| | | return xgeosDataConfigMapping; |
| | | } |
| | | |
| | | private void logTimeDiff(String message, long tBefore, long tCurrent) { |
| | | logger.warn(message + ":use time = " + ((int) ((tCurrent - tBefore) / 60000.0)) + " min - " + |
| | | (((int) ((tCurrent - tBefore) % 60000.0)) / 1000) + " sec"); |
| | | } |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { |
| | | |
| | | super.execute(jobExecutionContext); |
| | | |
| | | createTargetDataStore(); |
| | | |
| | | if (getTargetDataStore() == null) { |
| | | logger.warn("Cannot connect source postgreSQL database."); |
| | | throw new JobExecutionException("Cannot connect source postgreSQL database."); |
| | | } |
| | | |
| | | if (isProfileMode()) { |
| | | queryTime = 0; |
| | | } |
| | | |
| | | long t1 = System.currentTimeMillis(); |
| | | String targetSchemaName; |
| | | |
| | | try { |
| | | logger.info("-- step:resetPostgisViewMapping --"); |
| | | long tStep = System.currentTimeMillis(); |
| | | resetPostgisViewMapping(jobExecutionContext); |
| | | if (isProfileMode()) { |
| | | long tStepEnd = System.currentTimeMillis(); |
| | | logTimeDiff("Profile-resetPostgisViewMapping", tStep, tStepEnd); |
| | | } |
| | | logger.info("-- step:resetGeoServerConfig --"); |
| | | tStep = System.currentTimeMillis(); |
| | | // resetGeoServerConfig(jobExecutionContext); |
| | | if (isProfileMode()) { |
| | | long tStepEnd = System.currentTimeMillis(); |
| | | logTimeDiff("Profile-resetGeoServerConfig", tStep, tStepEnd); |
| | | } |
| | | } finally { |
| | | disconnect(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 重新建立所有重新建立所有PostGIS中的資料庫視景 |
| | | * |
| | | * @param executionContext 批次執行的關係 |
| | | */ |
| | | private void resetPostgisViewMapping(JobExecutionContext executionContext) { |
| | | assert executionContext != null; |
| | | Connection connection = null; |
| | | try { |
| | | connection = targetDataStore.getConnection(Transaction.AUTO_COMMIT); |
| | | String ownerName = _pgUsername; |
| | | String currentTargetSchema = retrieveCurrentSchemaName(connection, |
| | | DataReposVersionManager.VSSTATUS_READY); |
| | | if (currentTargetSchema == null) { |
| | | logger.info("Cannot found schema that status is VSSTATUS_READY[" + |
| | | DataReposVersionManager.VSSTATUS_READY + "]"); |
| | | return; |
| | | } |
| | | |
| | | ArrayList<String> realTableNames = new ArrayList<String>(); |
| | | retrieveAllRealTableName(connection, currentTargetSchema, realTableNames); |
| | | |
| | | HashMap<String, String> viewDefs = retrieveViewDef(connection, "public", "fsc%"); |
| | | HashMap<String, String> tempViewDefs = retrieveViewDef(connection, "public", "indexshape%"); |
| | | viewDefs.putAll(tempViewDefs); |
| | | tempViewDefs = viewDefs = retrieveViewDef(connection, "public", "lndtpc%"); |
| | | viewDefs.putAll(tempViewDefs); |
| | | |
| | | for (String tableName : realTableNames) { |
| | | resetPostgisDataView(connection, viewDefs, ownerName, currentTargetSchema, tableName); |
| | | } |
| | | |
| | | resetExtraPostgisDataView(connection, ownerName, currentTargetSchema, realTableNames); |
| | | |
| | | updateCurrentRepositoryStatus(connection, currentTargetSchema, |
| | | DataReposVersionManager.VSSTATUS_LINKVIEW); |
| | | |
| | | String currentTargetThemesName = retrieveCurrentThemeName(connection, |
| | | DataReposVersionManager.VSSTATUS_READY); |
| | | if (currentTargetThemesName == null) { |
| | | logger.info("Cannot found themes that status is VSSTATUS_READY[" + |
| | | DataReposVersionManager.VSSTATUS_READY + "]"); |
| | | return; |
| | | } |
| | | |
| | | resetThemesBaseView(connection, ownerName, currentTargetThemesName); |
| | | |
| | | XGeosDataConfigMapping configMapping = getConfigMapping(); |
| | | String[] allView = retrieveTargetStoreAllViewNames(connection); |
| | | TreeSet<String> allViewNames = new TreeSet<String>(); |
| | | if (allView != null) { |
| | | allViewNames.addAll(Arrays.asList(allView)); |
| | | } |
| | | List values = (List) configMapping.getMapping().get("pgOMS"); |
| | | for (Object value : values) { |
| | | XGeosDataConfig xgeosConfig = (XGeosDataConfig) value; |
| | | short tid = xgeosConfig.getFSC(); |
| | | short cid = xgeosConfig.getCOMP(); |
| | | StringBuilder sbTable = new StringBuilder("fsc-"); |
| | | sbTable.append(tid).append("-c-"); |
| | | sbTable.append(cid); |
| | | |
| | | int index = realTableNames.indexOf(sbTable.toString()); |
| | | if (index == -1) { |
| | | logger.debug("pgOMS LayerView Cannot found-" + xgeosConfig.toString()); |
| | | continue; |
| | | } |
| | | |
| | | StringBuilder sbView = new StringBuilder("fsc-"); |
| | | sbView.append(tid).append("-c"); |
| | | sbView.append(cid).append("-l"); |
| | | sbView.append(xgeosConfig.getLEV()).append("-w"); |
| | | sbView.append(xgeosConfig.getWEIGHT()); |
| | | String viewName = sbView.toString(); |
| | | if (allViewNames.contains(viewName)) { |
| | | resetThemesPostgisDataView(connection, ownerName, null, viewName); |
| | | } |
| | | } |
| | | |
| | | updateCurrentThemeStatus(connection, currentTargetThemesName, |
| | | DataReposVersionManager.VSSTATUS_LINKVIEW); |
| | | |
| | | // String[] featureNames = dataStore.getTypeNames(); |
| | | // logger.info("featureNames[] size = " + featureNames.length); |
| | | } catch (IOException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } finally { |
| | | if (connection != null) |
| | | JDBCUtils.close(connection, Transaction.AUTO_COMMIT, null); |
| | | // if (dataStore != null) dataStore.dispose(); |
| | | } |
| | | } |
| | | |
| | | private void retrieveAllRealTableName(Connection connection, String targetSchema, |
| | | ArrayList<String> realTableNames) throws SQLException { |
| | | ResultSet rsMeta = null; |
| | | try { |
| | | rsMeta = connection.getMetaData().getTables("", targetSchema, "fsc%", new String[]{"TABLE"}); |
| | | while (rsMeta.next()) { |
| | | String tableName = rsMeta.getString(3); |
| | | realTableNames.add(tableName); |
| | | } |
| | | rsMeta.close(); |
| | | rsMeta = null; |
| | | |
| | | rsMeta = connection.getMetaData().getTables("", targetSchema, "index%", new String[]{"TABLE"}); |
| | | while (rsMeta.next()) { |
| | | String tableName = rsMeta.getString(3); |
| | | realTableNames.add(tableName); |
| | | } |
| | | rsMeta.close(); |
| | | rsMeta = null; |
| | | |
| | | rsMeta = connection.getMetaData().getTables("", targetSchema, "lndtpc%", new String[]{"TABLE"}); |
| | | while (rsMeta.next()) { |
| | | String tableName = rsMeta.getString(3); |
| | | realTableNames.add(tableName); |
| | | } |
| | | } finally { |
| | | if (rsMeta != null) rsMeta.close(); |
| | | } |
| | | } |
| | | |
| | | private void resetPostgisDataView(Connection connection, HashMap<String, String> viewDefs, |
| | | String ownerName, String schemaName, String tableName) throws SQLException { |
| | | String[] splits = tableName.split("-"); |
| | | if (splits.length > 3) { |
| | | // feature table |
| | | |
| | | StringBuilder viewBuilder = new StringBuilder(); |
| | | viewBuilder.append(splits[0]); |
| | | viewBuilder.append('-'); |
| | | viewBuilder.append(splits[1]); |
| | | viewBuilder.append('-'); |
| | | viewBuilder.append(splits[2]); |
| | | viewBuilder.append(splits[3]); |
| | | String viewName = viewBuilder.toString(); |
| | | if (viewDefs.containsKey(viewName)) { |
| | | String viewDef = viewDefs.get(viewName); |
| | | int pos = viewDef.indexOf("FROM"); |
| | | String subView = viewDef.substring(pos + 4); |
| | | // String[] viewSources = subView.split("\\."); |
| | | String[] viewSources = subView.split("(\\.\"|\")"); |
| | | if (!viewSources[0].equalsIgnoreCase(schemaName)) { |
| | | createOrReplaceView(connection, schemaName, tableName, viewName, ownerName); |
| | | } |
| | | } else { |
| | | createOrReplaceView(connection, schemaName, tableName, viewName, ownerName); |
| | | } |
| | | |
| | | } else { |
| | | |
| | | splits = tableName.split("_"); |
| | | if (splits.length > 0) { |
| | | StringBuilder viewBuilder = new StringBuilder(); |
| | | viewBuilder.append(splits[0]); |
| | | if (splits.length > 1) viewBuilder.append(splits[1]); |
| | | if (splits.length > 2) viewBuilder.append(splits[2]); |
| | | String viewName = viewBuilder.toString(); |
| | | if (viewDefs.containsKey(viewName)) { |
| | | String viewDef = viewDefs.get(viewName); |
| | | int pos = viewDef.indexOf("FROM"); |
| | | String subView = viewDef.substring(pos + 4); |
| | | String[] viewSources = subView.split("(\\.\"|\")"); |
| | | if (!viewSources[0].equalsIgnoreCase(schemaName)) { |
| | | createOrReplaceView(connection, schemaName, tableName, viewName, ownerName); |
| | | } |
| | | } else { |
| | | createOrReplaceView(connection, schemaName, tableName, viewName, ownerName); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void resetExtraPostgisDataView(Connection connection, String ownerName, String currentSchema, |
| | | ArrayList<String> realTableNames) { |
| | | try { |
| | | // ArrayList<String> extraViewNames = new ArrayList<String>(); |
| | | XGeosDataConfigMapping configMapping = getConfigMapping(); |
| | | MultiMap configMultiMap = configMapping.getMapping(); |
| | | for (Object key : configMultiMap.keySet()) { |
| | | List values = (List) configMultiMap.get(key); |
| | | for (Object value : values) { |
| | | XGeosDataConfig xgeosConfig = (XGeosDataConfig) value; |
| | | short tid = xgeosConfig.getFSC(); |
| | | short cid = xgeosConfig.getCOMP(); |
| | | StringBuilder sbTable = new StringBuilder("fsc-"); |
| | | sbTable.append(tid).append("-c-"); |
| | | sbTable.append(cid); |
| | | int index = realTableNames.indexOf(sbTable.toString()); |
| | | if (index == -1) { |
| | | logger.debug("Cannot found-" + xgeosConfig.toString()); |
| | | continue; |
| | | } |
| | | StringBuilder sbView = new StringBuilder("fsc-"); |
| | | sbView.append(tid).append("-c"); |
| | | sbView.append(cid).append("-l"); |
| | | sbView.append(xgeosConfig.getLEV()).append("-w"); |
| | | sbView.append(xgeosConfig.getWEIGHT()); |
| | | // extraViewNames.add(sbView.toString()); |
| | | |
| | | createOrReplaceExtraView(connection, currentSchema, sbTable.toString(), sbView.toString(), |
| | | ownerName, xgeosConfig); |
| | | } |
| | | } |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | private void resetThemesBaseView(Connection connection, String ownerName, String currentThemesName) |
| | | throws SQLException { |
| | | String viewName = "xpwtheme" + FDYNCOLOR_SUFFIX; |
| | | String tableName = currentThemesName + FDYNCOLOR_SUFFIX; |
| | | PrintfFormat pf = new PrintfFormat("CREATE OR REPLACE VIEW \"%s\" AS SELECT * FROM \"%s\""); |
| | | String sql = pf.sprintf(new Object[]{viewName, tableName}); |
| | | Statement stmt = connection.createStatement(); |
| | | try { |
| | | stmt.execute(sql); |
| | | pf = new PrintfFormat(ALTER_VIEWSQL + ownerName); |
| | | sql = pf.sprintf(viewName); |
| | | stmt.execute(sql); |
| | | |
| | | viewName = "xpwtheme" + FOWNER_SUFFIX; |
| | | tableName = currentThemesName + FOWNER_SUFFIX; |
| | | pf = new PrintfFormat("CREATE OR REPLACE VIEW \"%s\" AS SELECT * FROM \"%s\""); |
| | | sql = pf.sprintf(new Object[]{viewName, tableName}); |
| | | |
| | | stmt.execute(sql); |
| | | pf = new PrintfFormat(ALTER_VIEWSQL + ownerName); |
| | | sql = pf.sprintf(viewName); |
| | | stmt.execute(sql); |
| | | } catch (SQLException e) { |
| | | // logger.warn(e.getMessage(), e); |
| | | logger.info(sql == null ? "SQL=NULL" : "SQL=" + sql); |
| | | throw e; |
| | | } finally { |
| | | stmt.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void resetThemesPostgisDataView(Connection connection, String ownerName, |
| | | String currentSchema, String viewName) throws SQLException { |
| | | String themeViewName = viewName + "-oms"; |
| | | // PrintfFormat pf = new PrintfFormat(CREATE_VIEWSQL); |
| | | // String sql = pf.sprintf(new Object[]{viewName, schemaName, tableName}); |
| | | ResultSet rs = null; |
| | | Statement stmt = connection.createStatement(); |
| | | |
| | | try { |
| | | StringBuilder sbSQL = new StringBuilder("CREATE OR REPLACE VIEW \""); |
| | | sbSQL.append(themeViewName).append("\" AS SELECT "); |
| | | |
| | | rs = connection.getMetaData().getColumns(null, currentSchema, viewName, "%"); |
| | | while (rs.next()) { |
| | | String fieldName = rs.getString("COLUMN_NAME"); |
| | | sbSQL.append("t." + fieldName).append(", "); |
| | | } |
| | | sbSQL.append("fc.dyncolor, fo.fowner FROM "); |
| | | if (currentSchema != null) |
| | | sbSQL.append("\"").append(currentSchema).append("\".\"").append(viewName).append("\" AS t,"); |
| | | else |
| | | sbSQL.append("\"").append(viewName).append("\" AS t,"); |
| | | sbSQL.append("xpwtheme").append(FDYNCOLOR_SUFFIX).append(" AS fc,"); |
| | | sbSQL.append("xpwtheme").append(FOWNER_SUFFIX).append(" AS fo WHERE "); |
| | | sbSQL.append("t.tid = fc.tid AND t.oid = fc.oid AND "); |
| | | sbSQL.append("t.tid = fo.tid AND t.oid = fo.oid"); |
| | | |
| | | // sbSQL.delete(sbSQL.length() - 2, sbSQL.length()); |
| | | String sql = sbSQL.toString(); |
| | | stmt.execute(sql); |
| | | sbSQL.delete(0, sbSQL.length()); |
| | | |
| | | PrintfFormat pf = new PrintfFormat(ALTER_VIEWSQL + ownerName); |
| | | sql = pf.sprintf(themeViewName); |
| | | stmt.execute(sql); |
| | | } finally { |
| | | JDBCUtils.close(rs); |
| | | JDBCUtils.close(stmt); |
| | | } |
| | | } |
| | | |
| | | private HashMap<String, String> retrieveViewDef(Connection connection, String schemaName, String tablePattern) throws SQLException { |
| | | PreparedStatement stmt = connection.prepareStatement(QUERY_VIEWDEFSQL + "'" + tablePattern + "'"); |
| | | stmt.setString(1, schemaName); |
| | | // stmt.setString(2, tablePattern); |
| | | HashMap<String, String> result = new HashMap<String, String>(); |
| | | ResultSet rs = stmt.executeQuery(); |
| | | while (rs.next()) { |
| | | String tableName = rs.getString(1); |
| | | String viewDef = rs.getString(2); |
| | | result.put(tableName, viewDef); |
| | | } |
| | | rs.close(); |
| | | stmt.close(); |
| | | return result; |
| | | } |
| | | |
| | | private void createOrReplaceView(Connection connection, String schemaName, String tableName, String viewName, |
| | | String ownerName) throws SQLException { |
| | | PrintfFormat pf = new PrintfFormat(CREATE_VIEWSQL); |
| | | String sql = pf.sprintf(new Object[]{viewName, schemaName, tableName}); |
| | | Statement stmt = connection.createStatement(); |
| | | try { |
| | | stmt.execute(sql); |
| | | pf = new PrintfFormat(ALTER_VIEWSQL + ownerName); |
| | | sql = pf.sprintf(viewName); |
| | | stmt.execute(sql); |
| | | } catch (SQLException e) { |
| | | // logger.warn(e.getMessage(), e); |
| | | logger.info(sql == null ? "SQL=NULL" : "SQL=" + sql); |
| | | throw e; |
| | | } finally { |
| | | stmt.close(); |
| | | } |
| | | // connection.commit(); |
| | | } |
| | | |
| | | private void createOrReplaceExtraView(Connection connection, String schemaName, String tableName, String viewName, |
| | | String ownerName, XGeosDataConfig xgeosConfig) throws SQLException { |
| | | PrintfFormat pf = new PrintfFormat(CREATE_VIEWSQL); |
| | | String sql = pf.sprintf(new Object[]{viewName, schemaName, tableName}); |
| | | |
| | | PrintfFormat pfWhere = new PrintfFormat(EXTRAWHERE_VIEWSQL); |
| | | sql += pfWhere.sprintf(new String[]{tableName, Short.toString(xgeosConfig.getLEV()), |
| | | tableName, Short.toString(xgeosConfig.getWEIGHT())}); |
| | | |
| | | Statement stmt = connection.createStatement(); |
| | | stmt.execute(sql); |
| | | |
| | | pf = new PrintfFormat(ALTER_VIEWSQL + ownerName); |
| | | sql = pf.sprintf(viewName); |
| | | stmt.execute(sql); |
| | | stmt.close(); |
| | | // connection.commit(); |
| | | } |
| | | |
| | | private Timestamp retrieveCurrentSchemaTimestamp(Connection connection, short status) throws SQLException { |
| | | StringBuilder sbSQL = new StringBuilder("SELECT vstimestamp, vsschema, vsstatus FROM "); |
| | | sbSQL.append(DataReposVersionManager.XGVERSIONTABLE_NAME); |
| | | sbSQL.append(" WHERE vsstatus = "); |
| | | sbSQL.append(status); |
| | | sbSQL.append(" ORDER BY vsid"); |
| | | |
| | | Timestamp result = null; |
| | | Statement stmt = null; |
| | | ResultSet rs = null; |
| | | |
| | | try { |
| | | stmt = connection.createStatement(); |
| | | rs = stmt.executeQuery(sbSQL.toString()); |
| | | // get first result |
| | | if (rs.next()) { |
| | | result = rs.getTimestamp(1); |
| | | } |
| | | return result; |
| | | } finally { |
| | | if (rs != null) rs.close(); |
| | | if (stmt != null) stmt.close(); |
| | | } |
| | | } |
| | | |
| | | private void updateCurrentRepositoryStatus(Connection connection, String schemaName, short newStatus) |
| | | throws SQLException { |
| | | StringBuilder sbSQL = new StringBuilder("UPDATE "); |
| | | sbSQL.append(DataReposVersionManager.XGVERSIONTABLE_NAME).append(' '); |
| | | sbSQL.append(" SET vsstatus = "); |
| | | sbSQL.append(newStatus); |
| | | sbSQL.append(", vstimestamp = CURRENT_TIMESTAMP WHERE vsschema = '"); |
| | | sbSQL.append(schemaName).append("'"); |
| | | |
| | | Statement stmt = null; |
| | | try { |
| | | stmt = connection.createStatement(); |
| | | stmt.executeUpdate(sbSQL.toString()); |
| | | } finally { |
| | | if (stmt != null) stmt.close(); |
| | | } |
| | | } |
| | | |
| | | private boolean checkCurrentRepositoryStatus(Connection connection, short status) { |
| | | try { |
| | | return (retrieveCurrentSchemaName(connection, status) != null); |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private String retrieveCurrentSchemaName(Connection connection, short status) throws SQLException { |
| | | StringBuilder sbSQL = new StringBuilder("SELECT vsschema, vstimestamp, vsstatus FROM "); |
| | | sbSQL.append(DataReposVersionManager.XGVERSIONTABLE_NAME); |
| | | sbSQL.append(" WHERE vsstatus = "); |
| | | sbSQL.append(status); |
| | | sbSQL.append(" ORDER BY vsid"); |
| | | |
| | | String result = null; |
| | | Statement stmt = null; |
| | | ResultSet rs = null; |
| | | |
| | | try { |
| | | stmt = connection.createStatement(); |
| | | rs = stmt.executeQuery(sbSQL.toString()); |
| | | // get first result |
| | | if (rs.next()) { |
| | | result = rs.getString(1); |
| | | } |
| | | return result; |
| | | } finally { |
| | | if (rs != null) rs.close(); |
| | | if (stmt != null) stmt.close(); |
| | | } |
| | | } |
| | | |
| | | private void updateCurrentThemeStatus(Connection connection, String schemaName, short newStatus) |
| | | throws SQLException { |
| | | StringBuilder sbSQL = new StringBuilder("UPDATE "); |
| | | sbSQL.append(DataReposVersionManager.XPTVERSIONTABLE_NAME).append(' '); |
| | | sbSQL.append(" SET vptstatus = "); |
| | | sbSQL.append(newStatus); |
| | | sbSQL.append(", vpttimestamp = CURRENT_TIMESTAMP WHERE vptname = '"); |
| | | sbSQL.append(schemaName).append("'"); |
| | | |
| | | Statement stmt = null; |
| | | try { |
| | | stmt = connection.createStatement(); |
| | | stmt.executeUpdate(sbSQL.toString()); |
| | | } finally { |
| | | if (stmt != null) stmt.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | private boolean checkCurrentThemeStatus(Connection connection, short status) { |
| | | try { |
| | | return (retrieveCurrentThemeName(connection, status) != null); |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | private String retrieveCurrentThemeName(Connection connection, short status) throws SQLException { |
| | | StringBuilder sbSQL = new StringBuilder("SELECT "); |
| | | sbSQL.append("vptname, vptstatus, vpttimestamp FROM "); |
| | | sbSQL.append(encodeSchemaTableName(_pgSchema, DataReposVersionManager.XPTVERSIONTABLE_NAME)).append(' '); |
| | | sbSQL.append("ORDER BY vptid"); |
| | | |
| | | String result = null; |
| | | Statement stmt = null; |
| | | ResultSet rs = null; |
| | | |
| | | try { |
| | | stmt = connection.createStatement(); |
| | | rs = stmt.executeQuery(sbSQL.toString()); |
| | | // get first result |
| | | if (rs.next()) { |
| | | result = rs.getString(1); |
| | | } |
| | | return result; |
| | | } finally { |
| | | JDBCUtils.close(rs); |
| | | JDBCUtils.close(stmt); |
| | | } |
| | | } |
| | | |
| | | protected void transferXGeosVersionStatus(Connection connection, |
| | | short vsstatusBefore, short vsstatusAfter, boolean exclusive) throws JobExecutionException { |
| | | |
| | | try { |
| | | String currentTargetSchema = retrieveCurrentSchemaName(connection, vsstatusBefore); |
| | | if (currentTargetSchema == null) { |
| | | logger.info("Cannot found target schema in dataStore. status=" + vsstatusBefore); |
| | | return; |
| | | } |
| | | String existTargetSchema = null; |
| | | if (exclusive) |
| | | existTargetSchema = retrieveCurrentSchemaName(connection, vsstatusAfter); |
| | | |
| | | |
| | | updateCurrentRepositoryStatus(connection, currentTargetSchema, vsstatusAfter); |
| | | if ((exclusive) && (existTargetSchema != null)) { |
| | | updateCurrentRepositoryStatus(connection, existTargetSchema, |
| | | DataReposVersionManager.VSSTATUS_AVAILABLE); |
| | | } |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException("Update " + DataReposVersionManager.XGVERSIONTABLE_NAME + |
| | | " has error-", e); |
| | | } |
| | | } |
| | | |
| | | private HashMap<String, String> buildDefaultStylesMapping(XGeosDataConfigMapping configMapping) { |
| | | HashMap<String, String> result = new HashMap<String, String>(); |
| | | |
| | | for (Object key : configMapping.getMapping().keySet()) { |
| | | List xgeosConfigs = (List) configMapping.getMapping().get(key); |
| | | for (Object value : xgeosConfigs) { |
| | | XGeosDataConfig xgeosConfig = (XGeosDataConfig) value; |
| | | |
| | | StringBuilder sbView = new StringBuilder("fsc-"); |
| | | sbView.append(xgeosConfig.getFSC()).append("-c"); |
| | | sbView.append(xgeosConfig.getCOMP()).append("-l"); |
| | | sbView.append(xgeosConfig.getLEV()).append("-w"); |
| | | sbView.append(xgeosConfig.getWEIGHT()); |
| | | |
| | | String viewName = sbView.toString(); |
| | | if (!result.containsKey(viewName)) { |
| | | result.put(viewName, xgeosConfig.getFTYPE()); |
| | | } else { |
| | | if (xgeosConfig.getFTYPE() != null) { |
| | | if (!result.get(viewName).equals(xgeosConfig.getFTYPE())) |
| | | logger.info("Style Define Diff:" + result.get(viewName) + " - " + xgeosConfig.getFTYPE()); |
| | | } else { |
| | | logger.warn("xgeosConfig getFTYPE() is null - " + xgeosConfig.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private String buildDefaultWMSLayerNames(String namespace, List xgeosConfigs, GSLayerGroupEncoder lgEncoder) { |
| | | StringBuilder sbLayers = new StringBuilder(); |
| | | boolean first = true; |
| | | |
| | | for (Object value : xgeosConfigs) { |
| | | if (!first) { |
| | | sbLayers.append(','); |
| | | } else { |
| | | first = false; |
| | | } |
| | | XGeosDataConfig xgeosConfig = (XGeosDataConfig) value; |
| | | |
| | | StringBuilder sbLayerName = new StringBuilder(namespace); |
| | | sbLayerName.append(':'); |
| | | sbLayerName.append("fsc-"); |
| | | sbLayerName.append(xgeosConfig.getFSC()).append("-c"); |
| | | sbLayerName.append(xgeosConfig.getCOMP()).append("-l"); |
| | | sbLayerName.append(xgeosConfig.getLEV()).append("-w"); |
| | | sbLayerName.append(xgeosConfig.getWEIGHT()); |
| | | |
| | | String layerName = sbLayerName.toString(); |
| | | sbLayers.append(layerName); |
| | | if (lgEncoder != null) { |
| | | lgEncoder.addLayer(layerName); |
| | | } |
| | | } |
| | | |
| | | return sbLayers.toString(); |
| | | } |
| | | |
| | | protected String[] retrieveTargetStoreAllViewNames(Connection connection) { |
| | | try { |
| | | final int TABLE_NAME_COL = 3; |
| | | List list = new ArrayList(); |
| | | |
| | | DatabaseMetaData meta = connection.getMetaData(); |
| | | // String[] tableType = { "TABLE", "VIEW" }; |
| | | String[] tableType = { "VIEW" }; |
| | | ResultSet tables = meta.getTables(null, _pgSchema, "%", tableType); |
| | | |
| | | while (tables.next()) { |
| | | String tableName = tables.getString(TABLE_NAME_COL); |
| | | list.add(tableName); |
| | | /* |
| | | if (allowTable(tableName)) { |
| | | list.add(tableName); |
| | | } |
| | | */ |
| | | } |
| | | tables.close(); |
| | | return (String[]) list.toArray(new String[list.size()]); |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private void resetFeatureTypesMapping(JobExecutionContext executionContext, GeoServerRESTManager manager) { |
| | | try { |
| | | GeoServerRESTReader reader = manager.getReader(); |
| | | GeoServerRESTPublisher publisher = manager.getPublisher(); |
| | | |
| | | Connection connection = targetDataStore.getConnection(Transaction.AUTO_COMMIT); |
| | | if (!checkCurrentRepositoryStatus(connection, DataReposVersionManager.VSSTATUS_CONFIG)) { |
| | | return; |
| | | } |
| | | |
| | | List<String> styleList = reader.getStyles().getNames(); |
| | | Set<String> styles = new TreeSet<String>(styleList); |
| | | |
| | | XGeosDataConfigMapping mapping = getConfigMapping(); |
| | | HashMap<String, String> defaultStyles = buildDefaultStylesMapping(mapping); |
| | | |
| | | try { |
| | | String[] dsFTypeNames = retrieveTargetStoreAllViewNames(connection); |
| | | |
| | | for (String featureTypeName : dsFTypeNames) { |
| | | FeatureType featureType = null; |
| | | try { |
| | | featureType = targetDataStore.getFeatureSource(featureTypeName, Transaction.AUTO_COMMIT).getSchema(); |
| | | } catch (IOException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | if (featureType == null) continue; |
| | | |
| | | RESTLayer layer = reader.getLayer(DEFAULT_NAMESPACE, featureTypeName); |
| | | if (layer != null) { |
| | | // publisher.removeLayer(DEFAULT_NAMESPACE, featureTypeName); |
| | | if (!publisher.unpublishFeatureType(DEFAULT_NAMESPACE, DEFAULT_STORENAME, featureTypeName)) { |
| | | logger.info("Cannot remove featureType:" + featureTypeName); |
| | | } |
| | | } |
| | | |
| | | final GSFeatureTypeEncoder fte = new GSFeatureTypeEncoder(); |
| | | |
| | | // fte.setProjectionPolicy(GSResourceEncoder.ProjectionPolicy.REPROJECT_TO_DECLARED); |
| | | fte.setProjectionPolicy(GSResourceEncoder.ProjectionPolicy.FORCE_DECLARED); |
| | | fte.addKeyword("KEYWORD"); |
| | | fte.setTitle(featureTypeName); |
| | | fte.setName(featureTypeName); |
| | | String srs = "EPSG:" + SRSID_TWD97_ZONE121; |
| | | if (!this._useZone121) { |
| | | srs = "EPSG:" + SRSID_TWD97_ZONE119; |
| | | } |
| | | fte.setNativeCRS(srs); |
| | | fte.setSRS(srs); // srs=null?"EPSG:4326":srs); |
| | | |
| | | String defaultStyle = getDefaultFeatureTypeStyleId(styles, defaultStyles, featureType); |
| | | final GSLayerEncoder le = new GSLayerEncoder(); |
| | | le.setDefaultStyle(defaultStyle); |
| | | |
| | | if (!publisher.publishDBLayer(DEFAULT_NAMESPACE, DEFAULT_STORENAME, fte, le)) { |
| | | logger.info("Create Feature Failed. [" + featureTypeName + "]"); |
| | | } |
| | | } |
| | | } finally { |
| | | // if (dataStore != null) dataStore.dispose(); |
| | | if (connection != null) |
| | | JDBCUtils.close(connection, Transaction.AUTO_COMMIT, null); |
| | | |
| | | } |
| | | } catch (IOException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | private void resetGeoServerConfig(JobExecutionContext jobExecutionContext) throws JobExecutionException { |
| | | Connection connection = null; |
| | | try { |
| | | connection = targetDataStore.getConnection(Transaction.AUTO_COMMIT); |
| | | transferXGeosVersionStatus(connection, DataReposVersionManager.VSSTATUS_LINKVIEW, |
| | | DataReposVersionManager.VSSTATUS_CONFIG, false); |
| | | URL geoServerURL = new URL(_geoServerURL); |
| | | GeoServerRESTManager manager = new GeoServerRESTManager(geoServerURL, _geoServerUser, _geoServerPass); |
| | | GeoServerRESTReader reader = manager.getReader(); |
| | | List<String> workSpaces = reader.getWorkspaceNames(); |
| | | boolean found = false; |
| | | for (String name : workSpaces) { |
| | | if (name.equalsIgnoreCase(DEFAULT_NAMESPACE)) { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | GeoServerRESTPublisher publisher = manager.getPublisher(); |
| | | if (!found) { |
| | | publisher.createWorkspace(DEFAULT_NAMESPACE, new URI(DEFAULT_GEODMMS_NAMESPACE)); |
| | | } |
| | | |
| | | RESTDataStore dataStore = reader.getDatastore(DEFAULT_NAMESPACE, DEFAULT_STORENAME); |
| | | if (dataStore == null) { |
| | | GeoServerRESTStoreManager storeManager = manager.getStoreManager(); |
| | | GSPostGISDatastoreEncoder store = new GSPostGISDatastoreEncoder(DEFAULT_STORENAME); |
| | | store.setHost(_pgHost); |
| | | store.setPort(Integer.parseInt(_pgPort)); |
| | | store.setDatabase(_pgDatabase); |
| | | store.setSchema(_pgSchema); |
| | | store.setUser(_pgUsername); |
| | | store.setPassword(_pgPassword); |
| | | storeManager.create(DEFAULT_NAMESPACE, store); |
| | | } |
| | | |
| | | |
| | | resetFeatureTypesMapping(jobExecutionContext, manager); |
| | | |
| | | resetGeoserverWMSConfig(jobExecutionContext, connection, manager, true); |
| | | resetWMSVirtualLayerMapping(jobExecutionContext, connection, manager, true); |
| | | |
| | | transferXGeosVersionStatus(connection, DataReposVersionManager.VSSTATUS_CONFIG, |
| | | DataReposVersionManager.VSSTATUS_USING, true); |
| | | Date lastUpdate = Calendar.getInstance().getTime(); |
| | | } catch (IOException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException("resetGeoServerConfig has error-" + e.getMessage(), e); |
| | | } catch (URISyntaxException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException("resetGeoServerConfig has error-" + e.getMessage(), e); |
| | | } finally { |
| | | if (connection != null) |
| | | JDBCUtils.close(connection, Transaction.AUTO_COMMIT, null); |
| | | |
| | | } |
| | | } |
| | | |
| | | protected String getDefaultFeatureTypeStyleId(Set<String> styles, HashMap<String, String> defaultStyles, FeatureType featureType) { |
| | | String ftName = featureType.getName().getLocalPart(); |
| | | boolean isNormalFeature = false; |
| | | boolean isLandBased = false; |
| | | boolean isIndex = false; |
| | | boolean isSmallIndex = false; |
| | | boolean isSymbol = false; |
| | | GeometryDescriptor geomAttrType = featureType.getGeometryDescriptor(); |
| | | Class geomType = geomAttrType.getType().getBinding(); |
| | | if (defaultStyles.containsKey(ftName)) { |
| | | String defaultStyleName = defaultStyles.get(ftName); |
| | | String styleName = retrieveDefaultStyle(styles, defaultStyleName, "unknown"); |
| | | if (!styleName.equals("unknown")) { |
| | | return styleName; |
| | | } |
| | | } |
| | | |
| | | if (ftName.indexOf("fsc") != -1) { |
| | | isNormalFeature = true; |
| | | } |
| | | if (ftName.indexOf("indexshape") != -1) { |
| | | isIndex = true; |
| | | } |
| | | if (ftName.indexOf("indexshapes") != -1) { |
| | | isSmallIndex = true; |
| | | } |
| | | if (ftName.indexOf("lnd") != -1) { |
| | | isLandBased = true; |
| | | } |
| | | if (featureType.getDescriptor("symbol") != null) { |
| | | isSymbol = true; |
| | | } |
| | | |
| | | if (Point.class.equals(geomType)) { |
| | | if (isSymbol) { |
| | | return retrieveDefaultStyle(styles, "xtpc-symbol", "point"); |
| | | } else if (isIndex) { |
| | | return retrieveDefaultStyle(styles, "xtpc-text2", "point"); |
| | | } else { |
| | | return retrieveDefaultStyle(styles, "xtpc-text", "point"); |
| | | } |
| | | } else if (LineString.class.equals(geomType)) { |
| | | if ((!isIndex) && (!isLandBased)) { |
| | | return retrieveDefaultStyle(styles, "xtpc-conductor", "line"); |
| | | } else if (isIndex) { |
| | | if (isSmallIndex) |
| | | return retrieveDefaultStyle(styles, "xtpc-indexshapes", "line"); |
| | | |
| | | return retrieveDefaultStyle(styles, "xtpc-indexshape", "line"); |
| | | } else if (isLandBased) { |
| | | return retrieveDefaultStyle(styles, "xtpc-lndcityLine", "line"); |
| | | } |
| | | } else if (MultiPoint.class.equals(geomType)) { |
| | | if (isSymbol) { |
| | | return retrieveDefaultStyle(styles, "xtpc-symbol", "point"); |
| | | } else { |
| | | return retrieveDefaultStyle(styles, "xtpc-text", "point"); |
| | | } |
| | | } else if (Polygon.class.equals(geomType)) { |
| | | if (isSymbol) { |
| | | return retrieveDefaultStyle(styles, "xtpc-symbol", "polygon"); |
| | | } else if ((!isIndex) && (!isLandBased)) { |
| | | return retrieveDefaultStyle(styles, "polygon", "polygon"); |
| | | } else if (isIndex) { |
| | | return retrieveDefaultStyle(styles, "xtpc-indexshape", "polygon"); |
| | | } else if (isLandBased) { |
| | | return retrieveDefaultStyle(styles, "xtpc-lndcityPolygon", "polygon"); |
| | | } |
| | | } else if (LinearRing.class.equals(geomType)) { |
| | | if (!isIndex) { |
| | | return retrieveDefaultStyle(styles, "polygon", "polygon"); |
| | | } else { |
| | | return retrieveDefaultStyle(styles, "xtpc-indexshape", "polygon"); |
| | | } |
| | | } else if (MultiLineString.class.equals(geomType)) { |
| | | if ((!isIndex) && (!isLandBased)) { |
| | | return retrieveDefaultStyle(styles, "xtpc-conductor", "line"); |
| | | } else if (isLandBased) { |
| | | return retrieveDefaultStyle(styles, "xtpc-lndcityLine", "line"); |
| | | } else { |
| | | return retrieveDefaultStyle(styles, "xtpc-indexshape", "line"); |
| | | } |
| | | } else if (MultiPolygon.class.equals(geomType)) { |
| | | return "polygon"; |
| | | } |
| | | |
| | | return "xtpc-symbol"; |
| | | } |
| | | |
| | | private static String retrieveDefaultStyle(Set styles, String styleName, String defaultStyleName) { |
| | | if (styles.contains(styleName)) { |
| | | return styleName; |
| | | } else |
| | | return defaultStyleName; |
| | | } |
| | | |
| | | protected void resetGeoserverWMSConfig(JobExecutionContext executionContext, Connection connection, |
| | | GeoServerRESTManager manager, boolean masterMode) |
| | | throws JobExecutionException, IOException { |
| | | |
| | | if ((masterMode) && (!checkCurrentRepositoryStatus(connection, DataReposVersionManager.VSSTATUS_CONFIG))) { |
| | | return; |
| | | } |
| | | |
| | | GeoServerRESTReader reader = manager.getReader(); |
| | | GeoServerRESTPublisher publisher = manager.getPublisher(); |
| | | |
| | | List<String> baseMapNames = reader.getLayers().getNames(); |
| | | XGeosDataConfigMapping configMapping = getConfigMapping(); |
| | | if (configMapping.getMapping().isEmpty()) { |
| | | logger.warn("XGeosDataConfigMapping is empty! Pleace check XGeosDataConfig file."); |
| | | return; |
| | | } |
| | | |
| | | LinkedList defaultMapNames = new LinkedList(configMapping.getMapping().keySet()); |
| | | if (defaultMapNames.isEmpty()) { |
| | | logger.warn("DefaultMapNames is emptyin XGeosDataConfigMapping! Pleace check XGeosDataConfig file."); |
| | | } |
| | | |
| | | for (Object key : baseMapNames) { |
| | | String baseMapTitle = (String) key; |
| | | if (configMapping.getMapping().containsKey(baseMapTitle)) { |
| | | int index = defaultMapNames.indexOf(baseMapTitle); |
| | | if (index != -1) |
| | | defaultMapNames.remove(index); |
| | | |
| | | List configs = (List) configMapping.getMapping().get(baseMapTitle); |
| | | String defaultLayerNames = buildDefaultWMSLayerNames(DEFAULT_NAMESPACE, configs, null); |
| | | // wmsConfig.getBaseMapLayers().put(baseMapTitle, defaultLayerNames); |
| | | logger.info(baseMapTitle + ":" + defaultLayerNames); |
| | | } else { |
| | | logger.warn(key.toString() + "-lv='" + baseMapTitle + "' cannot found config information in XGeosDataConfigMapping."); |
| | | } |
| | | } |
| | | |
| | | for (Object key : defaultMapNames) { |
| | | List configs = (List) configMapping.getMapping().get(key); |
| | | GSLayerGroupEncoder lge = new GSLayerGroupEncoder23() { |
| | | @Override |
| | | protected void addToRoot(Element... elements) { |
| | | for (Element e : elements) { |
| | | if (e != null) { |
| | | getRoot().addContent(e.cloneContent()); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | lge.setBounds("EPSG:3826",293838.061931726,2758423.49415501,311845.457747425,2768966.72993585); |
| | | String defaultLayerNames = buildDefaultWMSLayerNames(DEFAULT_NAMESPACE, configs, lge); |
| | | // logger.info(key + ":" + defaultLayerNames); |
| | | // logger.info(lge.toString()); |
| | | // wmsConfig.getBaseMapLayers().put(key, defaultLayerNames); |
| | | String layerGroupName = key.toString(); |
| | | RESTLayerGroup layerGroup = reader.getLayerGroup(DEFAULT_NAMESPACE, layerGroupName); |
| | | if (layerGroup == null) { |
| | | if (!publisher.createLayerGroup(DEFAULT_NAMESPACE, layerGroupName, lge)) { |
| | | logger.warn("Cannot create layergroups:" + layerGroupName + "-" + lge.toString()); |
| | | } |
| | | } else { |
| | | publisher.configureLayerGroup(DEFAULT_NAMESPACE, layerGroupName, lge); |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void resetWMSVirtualLayerMapping(JobExecutionContext jobExecutionContext, Connection connection, |
| | | GeoServerRESTManager manager, boolean masterMode) |
| | | throws JobExecutionException, IOException { |
| | | if ((masterMode) && (!checkCurrentRepositoryStatus(connection, DataReposVersionManager.VSSTATUS_CONFIG))) { |
| | | return; |
| | | } |
| | | |
| | | GeoServerRESTReader reader = manager.getReader(); |
| | | List<String> layernames = reader.getLayers().getNames(); |
| | | ArrayList<String> baseMapNames = new ArrayList<String>(layernames); |
| | | // Map baseMapLayers = wmsConfig.getBaseMapLayers(); |
| | | // Map baseMapEnvelopes = wmsConfig.getBaseMapEnvelopes(); |
| | | |
| | | for (Object key : baseMapNames) { |
| | | String baseMapTitle = (String) key; |
| | | if (baseMapTitle.startsWith("pg")) { |
| | | // GeneralEnvelope envelope = (GeneralEnvelope) baseMapEnvelopes.get(baseMapTitle); |
| | | |
| | | GeneralEnvelope selectedEnvelope = null; |
| | | // String baseLayersValue = (String) wmsConfig.getBaseMapLayers().get(baseMapTitle); |
| | | RESTLayerGroup layerGroup = reader.getLayerGroup(DEFAULT_NAMESPACE, baseMapTitle); |
| | | String baseLayersValue = layerGroup.getName(); |
| | | String[] layerNames = null; |
| | | if (baseLayersValue != null) { |
| | | layerNames = baseLayersValue.split(","); |
| | | } else { |
| | | logger.info("vl='" + baseMapTitle + "' is empty value."); |
| | | continue; |
| | | } |
| | | |
| | | // RESTLayer layer = reader.getLayer(DEFAULT_NAMESPACE, baseMapTitle); |
| | | // layer.Type. |
| | | |
| | | ArrayList<String> newLayerNames = new ArrayList<String>(); |
| | | for (int i = 0; i < layerNames.length; i++) { |
| | | String layerName = layerNames[i].trim(); |
| | | newLayerNames.add(layerName); |
| | | |
| | | /* |
| | | Integer layerType = catalog.getLayerType(layerName); |
| | | if (layerType != null) { |
| | | newLayerNames.add(layerName); |
| | | |
| | | if (layerType.intValue() == MapLayerInfo.TYPE_VECTOR) { |
| | | FeatureTypeInfo ftype = catalog.getFeatureTypeInfo(layerName); |
| | | ftype = ((ftype != null) ? ftype |
| | | : catalog.getFeatureTypeInfo(layerName |
| | | .substring(layerName.indexOf(":") + 1, layerName.length()))); |
| | | |
| | | if (selectedEnvelope == null) { |
| | | ReferencedEnvelope ftEnvelope = null; |
| | | |
| | | try { |
| | | if (ftype.getBoundingBox() instanceof ReferencedEnvelope |
| | | && !ftype.getBoundingBox().isNull()) { |
| | | ftEnvelope = ftype.getBoundingBox(); |
| | | } else { |
| | | // TODO Add Action Errors |
| | | return; |
| | | } |
| | | } catch (IOException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | return; |
| | | } |
| | | |
| | | selectedEnvelope = new GeneralEnvelope(new double[]{ |
| | | ftEnvelope.getMinX(), ftEnvelope.getMinY() |
| | | }, |
| | | new double[]{ftEnvelope.getMaxX(), ftEnvelope.getMaxY()}); |
| | | selectedEnvelope.setCoordinateReferenceSystem(ftEnvelope |
| | | .getCoordinateReferenceSystem()); |
| | | } else { |
| | | final CoordinateReferenceSystem dstCRS = selectedEnvelope |
| | | .getCoordinateReferenceSystem(); |
| | | |
| | | ReferencedEnvelope ftEnvelope = null; |
| | | |
| | | try { |
| | | if (ftype.getBoundingBox() instanceof ReferencedEnvelope) { |
| | | ftEnvelope = (ReferencedEnvelope) ftype.getBoundingBox(); |
| | | ftEnvelope.transform(dstCRS, true); |
| | | } else { |
| | | // TODO Add Action Errors |
| | | return; |
| | | } |
| | | } catch (TransformException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | return; |
| | | } catch (FactoryException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | return; |
| | | } catch (IOException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | return; |
| | | } |
| | | |
| | | ReferencedEnvelope newEnvelope = new ReferencedEnvelope(dstCRS); |
| | | newEnvelope.init(selectedEnvelope.getLowerCorner().getOrdinate(0), |
| | | selectedEnvelope.getUpperCorner().getOrdinate(0), |
| | | selectedEnvelope.getLowerCorner().getOrdinate(1), |
| | | selectedEnvelope.getUpperCorner().getOrdinate(1)); |
| | | |
| | | newEnvelope.expandToInclude(ftEnvelope); |
| | | |
| | | selectedEnvelope = new GeneralEnvelope(new double[]{ |
| | | newEnvelope.getMinX(), newEnvelope.getMinY() |
| | | }, |
| | | new double[]{newEnvelope.getMaxX(), newEnvelope.getMaxY()}); |
| | | selectedEnvelope.setCoordinateReferenceSystem(dstCRS); |
| | | } |
| | | } |
| | | } else { |
| | | logger.warn("Cannot found layer " + layerName + " in " + baseMapTitle); |
| | | } |
| | | */ |
| | | } |
| | | |
| | | if (layerNames.length != newLayerNames.size()) { |
| | | StringBuilder layerBuilder = new StringBuilder(); |
| | | boolean bFirst = true; |
| | | for (String newlayerName : newLayerNames) { |
| | | if (!bFirst) { |
| | | layerBuilder.append(','); |
| | | } else bFirst = false; |
| | | layerBuilder.append(newlayerName); |
| | | } |
| | | // baseMapLayers.put(baseMapTitle, layerBuilder.toString()); |
| | | logger.info(baseMapTitle +":"+ layerBuilder.toString()); |
| | | } |
| | | |
| | | /* |
| | | if (selectedEnvelope != null) { |
| | | if (envelope != null) { |
| | | envelope.setCoordinateReferenceSystem(selectedEnvelope |
| | | .getCoordinateReferenceSystem()); |
| | | envelope.setEnvelope(selectedEnvelope); |
| | | baseMapEnvelopes.put(baseMapTitle, envelope); |
| | | } else { |
| | | baseMapEnvelopes.put(baseMapTitle, selectedEnvelope); |
| | | } |
| | | } |
| | | */ |
| | | } |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ximple.eofms.jobs;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileFilter;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.FileNotFoundException;
|
| | | import java.io.FilenameFilter;
|
| | | import java.io.IOException;
|
| | | import java.math.BigDecimal;
|
| | | import java.nio.BufferOverflowException;
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | | import java.nio.channels.FileChannel;
|
| | | import java.sql.Connection;
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | | import java.sql.Statement;
|
| | | import java.sql.Types;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.TreeMap;
|
| | |
|
| | | import com.ximple.eofms.jobs.context.AbstractOracleJobContext;
|
| | | import com.ximple.eofms.jobs.context.edbgeo.FeatureDgnConvertEdbGeoJobContext;
|
| | | import com.ximple.eofms.jobs.context.edbgeo.GeneralDgnConvertEdbGeoJobContext;
|
| | | import com.ximple.eofms.jobs.context.edbgeo.IndexDgnConvertEdbGeoJobContext;
|
| | | import com.ximple.eofms.jobs.context.edbgeo.OracleConvertEdbGeoJobContext;
|
| | | import com.ximple.eofms.util.BinConverter;
|
| | | import com.ximple.eofms.util.ByteArrayCompressor;
|
| | | import com.ximple.eofms.util.FileUtils;
|
| | | import com.ximple.eofms.util.StringUtils;
|
| | | import com.ximple.io.dgn7.ComplexElement;
|
| | | import com.ximple.io.dgn7.Dgn7fileException;
|
| | | import com.ximple.io.dgn7.Dgn7fileReader;
|
| | | import com.ximple.io.dgn7.Element;
|
| | | import com.ximple.io.dgn7.ElementType;
|
| | | import com.ximple.io.dgn7.IElementHandler;
|
| | | import com.ximple.io.dgn7.Lock;
|
| | | import com.ximple.util.PrintfFormat;
|
| | | import oracle.jdbc.OracleConnection;
|
| | | import oracle.jdbc.OracleResultSet;
|
| | | import oracle.sql.ARRAY;
|
| | | import oracle.sql.BLOB;
|
| | | import org.apache.commons.collections.OrderedMap;
|
| | | import org.apache.commons.collections.OrderedMapIterator;
|
| | | import org.apache.commons.collections.map.LinkedMap;
|
| | | import org.apache.commons.logging.Log;
|
| | | import org.apache.commons.logging.LogFactory;
|
| | | import org.geotools.data.DataStore;
|
| | | import org.geotools.data.Transaction;
|
| | | import org.geotools.data.edbgeo.PostgisDataStoreFactory;
|
| | | import org.geotools.data.jdbc.JDBCUtils;
|
| | | import org.geotools.feature.SchemaException;
|
| | | import org.geotools.jdbc.JDBCDataStore;
|
| | | import org.opengis.feature.IllegalAttributeException;
|
| | | import org.quartz.JobDataMap;
|
| | | import org.quartz.JobDetail;
|
| | | import org.quartz.JobExecutionContext;
|
| | | import org.quartz.JobExecutionException;
|
| | |
|
| | | public class OracleConvertDgn2EdbGeoJob extends AbstractOracleDatabaseJob {
|
| | | final static Log logger = LogFactory.getLog(OracleConvertDgn2EdbGeoJob.class);
|
| | |
|
| | | private static final String EDBHOST = "EDBHOST";
|
| | | private static final String EDBDATBASE = "EDBDATBASE";
|
| | | private static final String EDBPORT = "EDBPORT";
|
| | | private static final String EDBSCHEMA = "EDBSCHEMA";
|
| | | private static final String EDBUSER = "EDBUSER";
|
| | | private static final String EDBPASS = "EDBPASS";
|
| | | private static final String USEWKB = "USEWKB";
|
| | |
|
| | | private static final boolean useTpclidText = false;
|
| | |
|
| | | private static final int FETCHSIZE = 30;
|
| | | private static final int COMMITSIZE = 100;
|
| | | private static final String INDEXPATHNAME = "index";
|
| | | private static final String OTHERPATHNAME = "other";
|
| | |
|
| | | protected static class Pair {
|
| | | Object first;
|
| | | Object second;
|
| | |
|
| | | public Pair(Object first, Object second) {
|
| | | this.first = first;
|
| | | this.second = second;
|
| | | }
|
| | | }
|
| | |
|
| | | protected static PostgisDataStoreFactory dataStoreFactory = new PostgisDataStoreFactory();
|
| | |
|
| | | protected String _edbHost;
|
| | | protected String _edbDatabase;
|
| | | protected String _edbPort;
|
| | | protected String _edbSchema;
|
| | | protected String _edbUsername;
|
| | | protected String _edbPassword;
|
| | | protected String _edbUseWKB;
|
| | |
|
| | | protected Map<String, String> edbProperties;
|
| | | protected JDBCDataStore targetDataStore;
|
| | | // protected OracleConvertEdbGeoJobContext oracleJobContext;
|
| | |
|
| | | private long queryTime = 0;
|
| | | private long queryTimeStart = 0;
|
| | |
|
| | | public Log getLogger() {
|
| | | return logger;
|
| | | }
|
| | |
|
| | | protected AbstractOracleJobContext prepareJobContext(String targetSchemaName, String filterPath,
|
| | | boolean profileMode,
|
| | | boolean useTransform) {
|
| | | return new OracleConvertEdbGeoJobContext(getDataPath(),
|
| | | getTargetDataStore(), targetSchemaName, filterPath, profileMode, useTransform);
|
| | | }
|
| | |
|
| | | protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException {
|
| | | super.extractJobConfiguration(jobDetail);
|
| | | JobDataMap dataMap = jobDetail.getJobDataMap();
|
| | | _edbHost = dataMap.getString(EDBHOST);
|
| | | _edbDatabase = dataMap.getString(EDBDATBASE);
|
| | | _edbPort = dataMap.getString(EDBPORT);
|
| | | _edbSchema = dataMap.getString(EDBSCHEMA);
|
| | | _edbUsername = dataMap.getString(EDBUSER);
|
| | | _edbPassword = dataMap.getString(EDBPASS);
|
| | | _edbUseWKB = dataMap.getString(USEWKB);
|
| | |
|
| | | Log logger = getLogger();
|
| | | /*
|
| | | logger.info("EDBHOST=" + _myHost);
|
| | | logger.info("EDBDATBASE=" + _myDatabase);
|
| | | logger.info("EDBPORT=" + _myPort);
|
| | | logger.info("EDBSCHEMA=" + _mySchema);
|
| | | logger.info("EDBUSER=" + _myUsername);
|
| | | logger.info("EDBPASS=" + _myPassword);
|
| | | logger.info("USEWKB=" + _myUseWKB);
|
| | | */
|
| | |
|
| | | if (_edbHost == null) {
|
| | | logger.warn("EDBHOST is null");
|
| | | throw new JobExecutionException("Unknown EdbGeoSpatial host.");
|
| | | }
|
| | | if (_edbDatabase == null) {
|
| | | logger.warn("PGDATABASE is null");
|
| | | throw new JobExecutionException("Unknown EdbGeoSpatial database.");
|
| | | }
|
| | | if (_edbPort == null) {
|
| | | logger.warn("EDBPORT is null");
|
| | | throw new JobExecutionException("Unknown EdbGeoSpatial port.");
|
| | | }
|
| | | if (_edbSchema == null) {
|
| | | logger.warn("EDBSCHEMA is null");
|
| | | throw new JobExecutionException("Unknown EdbGeoSpatial schema.");
|
| | | }
|
| | | if (_edbUsername == null) {
|
| | | logger.warn("PGUSERNAME is null");
|
| | | throw new JobExecutionException("Unknown EdbGeoSpatial username.");
|
| | | }
|
| | | if (_edbPassword == null) {
|
| | | logger.warn("PGPASSWORD is null");
|
| | | throw new JobExecutionException("Unknown EdbGeoSpatial password.");
|
| | | }
|
| | |
|
| | | Map<String, String> remote = new TreeMap<String, String>();
|
| | | remote.put("dbtype", "edbgeo");
|
| | | remote.put("charset", "UTF-8");
|
| | | remote.put("host", _edbHost);
|
| | | remote.put("port", _edbPort);
|
| | | remote.put("database", _edbDatabase);
|
| | | remote.put("user", _edbUsername);
|
| | | remote.put("passwd", _edbPassword);
|
| | | remote.put("namespace", null);
|
| | | edbProperties = remote;
|
| | | }
|
| | |
|
| | | public void execute(JobExecutionContext context) throws JobExecutionException {
|
| | | // Every job has its own job detail
|
| | | JobDetail jobDetail = context.getJobDetail();
|
| | |
|
| | | // The name is defined in the job definition
|
| | | String jobName = jobDetail.getKey().getName();
|
| | |
|
| | | // Log the time the job started
|
| | | logger.info(jobName + " fired at " + new Date());
|
| | | extractJobConfiguration(jobDetail);
|
| | | createSourceDataStore();
|
| | | createTargetDataStore();
|
| | | if (getSourceDataStore() == null) {
|
| | | logger.warn("Cannot connect source oracle database.");
|
| | | throw new JobExecutionException("Cannot connect source oracle database.");
|
| | | }
|
| | |
|
| | | if (getTargetDataStore() == null) {
|
| | | logger.warn("Cannot connect source postgreSQL database.");
|
| | | throw new JobExecutionException("Cannot connect source postgreSQL database.");
|
| | | }
|
| | |
|
| | | if (isProfileMode()) {
|
| | | queryTime = 0;
|
| | | }
|
| | |
|
| | | long t1 = System.currentTimeMillis();
|
| | | String targetSchemaName;
|
| | | try {
|
| | | logger.info("-- step:clearOutputDatabase --");
|
| | | clearOutputDatabase();
|
| | | targetSchemaName = determineTargetSchemaName();
|
| | |
|
| | | if (checkConvertFile()) {
|
| | | logger.info("-- step:convertIndexDesignFile --");
|
| | | long tStep = System.currentTimeMillis();
|
| | | convertIndexDesignFile(context, targetSchemaName);
|
| | | if (isProfileMode()) {
|
| | | long tStepEnd = System.currentTimeMillis();
|
| | | logTimeDiff("Profile-convertIndexDesignFile", tStep, tStepEnd);
|
| | | }
|
| | |
|
| | | logger.info("-- step:convertOtherDesignFile --");
|
| | | tStep = System.currentTimeMillis();
|
| | | convertOtherDesignFile(context, targetSchemaName);
|
| | | if (isProfileMode()) {
|
| | | long tStepEnd = System.currentTimeMillis();
|
| | | logTimeDiff("Profile-convertOtherDesignFile", tStep, tStepEnd);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | if (checkConvertDB()) {
|
| | | logger.info("-- step:convertOracleDB --");
|
| | |
|
| | | OracleConvertEdbGeoJobContext jobContext =
|
| | | (OracleConvertEdbGeoJobContext) prepareJobContext(targetSchemaName, _filterPath,
|
| | | isProfileMode(), isTransformed());
|
| | | jobContext.setSourceDataStore(getSourceDataStore());
|
| | | // jobContext.setConvertElementIn(_convertElementIn);
|
| | | jobContext.setElementLogging(checkElementLogging());
|
| | | jobContext.setExecutionContext(context);
|
| | |
|
| | | createHibernateSequence(jobContext);
|
| | | fetchTPData(jobContext);
|
| | | logger.info("TPC DIST:" + jobContext.getDistId() + ":" +
|
| | | ((jobContext.getDistName() == null) ? "NULL" : jobContext.getDistName()));
|
| | |
|
| | | long tStep = System.currentTimeMillis();
|
| | |
|
| | | if (isCopyConnectivityMode()) {
|
| | | copyConnectivity(jobContext);
|
| | | }
|
| | |
|
| | | if (isProfileMode()) {
|
| | | long tStepEnd = System.currentTimeMillis();
|
| | | logTimeDiff("Profile-Copy Connectivity", tStep, tStepEnd);
|
| | | }
|
| | |
|
| | | for (String orgSchema : _orgSchema) {
|
| | | logger.info("----- start schema:" + orgSchema + " -----");
|
| | | if (isProfileMode()) {
|
| | | jobContext.resetProcessTime();
|
| | | jobContext.resetUpdateTime();
|
| | | }
|
| | | tStep = System.currentTimeMillis();
|
| | | exetcuteConvert(jobContext, orgSchema, _dataPath);
|
| | |
|
| | | //close all open filewriter instance
|
| | | jobContext.closeFeatureWriter();
|
| | |
|
| | | if (isProfileMode()) {
|
| | | logger.warn("Profile-Current Query Oracle Cost-" +
|
| | | ((int) ((getQueryTime()) / 60000.0)) + " min - " +
|
| | | (((int) ((getQueryTime()) % 60000.0)) / 1000) + " sec");
|
| | | long tStepEnd = System.currentTimeMillis();
|
| | | logger.warn("Profile-Current Process Cost-" +
|
| | | ((int) ((getProcessTime()) / 60000.0)) + " min - " +
|
| | | (((int) ((getProcessTime()) % 60000.0)) / 1000) + " sec");
|
| | | logger.warn("Profile-Current Update Cost-" +
|
| | | ((int) ((getUpdateTime()) / 60000.0)) + " min - " +
|
| | | (((int) ((getUpdateTime()) % 60000.0)) / 1000) + " sec");
|
| | | logger.warn("Profile-Current JobContext Process Cost-" +
|
| | | ((int) ((jobContext.getProcessTime()) / 60000.0)) + " min - " +
|
| | | (((int) ((jobContext.getProcessTime()) % 60000.0)) / 1000) + " sec");
|
| | | logger.warn("Profile-Current JobContext Update Cost-" +
|
| | | ((int) ((jobContext.getUpdateTime()) / 60000.0)) + " min - " +
|
| | | (((int) ((jobContext.getUpdateTime()) % 60000.0)) / 1000) + " sec");
|
| | | logTimeDiff("Profile-Convert[" + orgSchema + "]", tStep, tStepEnd);
|
| | |
|
| | | resetQueryTime();
|
| | | resetProcessTime();
|
| | | resetUpdateTime();
|
| | | }
|
| | | }
|
| | |
|
| | | jobContext.closeOracleConnection();
|
| | | }
|
| | |
|
| | | if (checkConvertElementIn()) {
|
| | | logger.info("-- step:convertFeatureDesignFile --");
|
| | | long tStep = System.currentTimeMillis();
|
| | | convertFeatureDesignFile(context, targetSchemaName);
|
| | | if (isProfileMode()) {
|
| | | long tStepEnd = System.currentTimeMillis();
|
| | | logTimeDiff("Profile-convertFeatureDesignFile", tStep, tStepEnd);
|
| | | }
|
| | | }
|
| | |
|
| | | if (checkCreateDummy()) {
|
| | | logger.info("-- step:createDummyFeatureFile --");
|
| | | createDummyFeatureFile(context);
|
| | | }
|
| | |
|
| | | long t2 = System.currentTimeMillis();
|
| | | // public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
|
| | | // SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
|
| | | logTimeDiff("Total ", t1, t2);
|
| | |
|
| | | updateRepoStatusToReady(targetSchemaName);
|
| | |
|
| | | } catch (SQLException e) {
|
| | | disconnect();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException("Database error. " + e.getMessage(), e);
|
| | | } catch (IOException ex) {
|
| | | disconnect();
|
| | | logger.warn(ex.getMessage(), ex);
|
| | | throw new JobExecutionException("IO error. " + ex.getMessage(), ex);
|
| | | } finally {
|
| | | disconnect();
|
| | | }
|
| | | logger.warn(jobName + " end at " + new Date());
|
| | | }
|
| | |
|
| | | private void logTimeDiff(String message, long tBefore, long tCurrent) {
|
| | | logger.warn(message + ":use time = " + ((int) ((tCurrent - tBefore) / 60000.0)) + " min - " +
|
| | | (((int) ((tCurrent - tBefore) % 60000.0)) / 1000) + " sec");
|
| | | }
|
| | |
|
| | | private void exetcuteConvert(OracleConvertEdbGeoJobContext jobContext,
|
| | | String querySchema, String targetSchemaName) throws SQLException {
|
| | | int order = 0;
|
| | | OrderedMap map = getBlobStorageList(jobContext.getOracleConnection(),
|
| | | querySchema, "SD$SPACENODES", null);
|
| | |
|
| | | logger.info("begin convert job:[" + map.size() + "]:testmode=" + _testMode);
|
| | |
|
| | | int total = map.size(); //spacenodes count
|
| | | int step = total / 100;
|
| | | int current = 0;
|
| | |
|
| | | if (total == 0) {
|
| | | logger.warn("SELECT COUNT FROM " + querySchema + ".SD$SPACENODES is zero.");
|
| | | return;
|
| | | }
|
| | | logger.warn("SELECT COUNT FROM " + querySchema + ".SD$SPACENODES is " + map.size());
|
| | |
|
| | | //jobContext.startTransaction();
|
| | | jobContext.setCurrentSchema(querySchema);
|
| | | jobContext.getExecutionContext().put("ConvertDgn2EdbGeoJobProgress", 0);
|
| | | for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext(); ) {
|
| | | it.next();
|
| | |
|
| | | Pair pair = (Pair) it.getValue();
|
| | | String tableSrc = (String) pair.first;
|
| | |
|
| | | logger.info("begin convert:[" + order + "]-" + tableSrc);
|
| | | queryIgsetElement(jobContext, querySchema, tableSrc);
|
| | |
|
| | |
|
| | | order++;
|
| | |
|
| | | if (_testMode) {
|
| | | if ((_testCount < 0) || (order >= _testCount))
|
| | | break;
|
| | | }
|
| | |
|
| | | if ((order % COMMITSIZE) == 0) {
|
| | | // OracleConnection connection = jobContext.getOracleConnection();
|
| | | // connection.commitTransaction();
|
| | | jobContext.commitTransaction();
|
| | | //jobContext.startTransaction();
|
| | | System.gc();
|
| | | System.runFinalization();
|
| | | }
|
| | |
|
| | | if (step != 0) {
|
| | | int now = order % step;
|
| | | if (now != current) {
|
| | | current = now;
|
| | | jobContext.getExecutionContext().put("ConvertDgn2EdbGeoSpatialJob", current);
|
| | |
|
| | | }
|
| | | } else {
|
| | | jobContext.getExecutionContext().put("ConvertDgn2EdbGeoSpatialJob", current);
|
| | | current++;
|
| | | }
|
| | | }
|
| | | jobContext.getExecutionContext().put("ConvertDgn2EdbGeoSpatialJob", 100);
|
| | |
|
| | | jobContext.commitTransaction();
|
| | | jobContext.resetFeatureContext();
|
| | |
|
| | | if (isProfileMode()) {
|
| | |
|
| | | }
|
| | |
|
| | | logger.info("end convert job:[" + order + "]");
|
| | | System.gc();
|
| | | System.runFinalization();
|
| | | }
|
| | |
|
| | | protected OrderedMap getBlobStorageList(Connection connection, String schemaSrc, String tableSrc,
|
| | | OrderedMap orderedMap) throws SQLException {
|
| | | if (orderedMap == null)
|
| | | orderedMap = new LinkedMap(99);
|
| | | String fetchStmtFmt = "SELECT SNID, SPACETABLE FROM \"%s\".\"%s\"";
|
| | | PrintfFormat spf = new PrintfFormat(fetchStmtFmt);
|
| | | String fetchStmt = spf.sprintf(new Object[]{schemaSrc, tableSrc});
|
| | | Statement stmt = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
| | | ResultSet rs = null;
|
| | |
|
| | | stmt.setFetchSize(FETCHSIZE);
|
| | | try {
|
| | | rs = stmt.executeQuery(fetchStmt);
|
| | | int size = rs.getMetaData().getColumnCount();
|
| | |
|
| | | while (rs.next()) {
|
| | | Object[] values = new Object[size];
|
| | |
|
| | | for (int i = 0; i < size; i++) {
|
| | | values[i] = rs.getObject(i + 1);
|
| | | }
|
| | |
|
| | | Integer key = ((BigDecimal) values[0]).intValue();
|
| | | String name = (String) values[1];
|
| | |
|
| | | Pair pair = (Pair) orderedMap.get(key);
|
| | | if (pair == null)
|
| | | orderedMap.put(key, new Pair(name, null));
|
| | | else
|
| | | pair.first = name;
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | logger.error(e.toString(), e);
|
| | | logger.error("stmt=" + fetchStmt);
|
| | | throw e;
|
| | | } finally {
|
| | | JDBCUtils.close(rs);
|
| | | JDBCUtils.close(stmt);
|
| | | }
|
| | |
|
| | | return orderedMap;
|
| | | }
|
| | |
|
| | | protected OrderedMap getRawFormatStorageList(OracleConnection connection, String schemaSrc, String tableSrc,
|
| | | OrderedMap orderedMap) throws SQLException {
|
| | | if (orderedMap == null)
|
| | | orderedMap = new LinkedMap(99);
|
| | | String fetchStmtFmt = "SELECT RNID, SPACETABLE FROM \"%s\".\"%s\"";
|
| | | PrintfFormat spf = new PrintfFormat(fetchStmtFmt);
|
| | | String fetchStmt = spf.sprintf(new Object[]{schemaSrc, tableSrc});
|
| | | Statement stmt = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
| | |
|
| | | stmt.setFetchSize(FETCHSIZE);
|
| | | ResultSet rs = stmt.executeQuery(fetchStmt);
|
| | | try {
|
| | | int size = rs.getMetaData().getColumnCount();
|
| | | while (rs.next()) {
|
| | | Object[] values = new Object[size];
|
| | |
|
| | | for (int i = 0; i < size; i++) {
|
| | | values[i] = rs.getObject(i + 1);
|
| | | }
|
| | |
|
| | | Integer key = ((BigDecimal) values[0]).intValue();
|
| | | String name = (String) values[1];
|
| | |
|
| | | Pair pair = (Pair) orderedMap.get(key);
|
| | | if (pair == null)
|
| | | orderedMap.put(key, new Pair(null, name));
|
| | | else
|
| | | pair.second = name;
|
| | | }
|
| | | } finally {
|
| | | JDBCUtils.close(rs);
|
| | | JDBCUtils.close(stmt);
|
| | | }
|
| | | return orderedMap;
|
| | | }
|
| | |
|
| | | protected void queryIgsetElement(OracleConvertEdbGeoJobContext jobContext,
|
| | | String srcschema, String srctable) throws SQLException {
|
| | | Connection connection = jobContext.getOracleConnection();
|
| | | String fetchSrcStmtFmt = "SELECT IGDSELM FROM \"%s\".\"%s\" ORDER BY ROWID";
|
| | | //String fetchSrcStmtFmt = "SELECT IGDSELM FROM \"%s\".\"%s\" WHERE TAG_SFSC = 423 AND TAG_LUFID = 21612065 ORDER BY ROWID";
|
| | | PrintfFormat spf = new PrintfFormat(fetchSrcStmtFmt);
|
| | | String fetchSrcStmt = spf.sprintf(new Object[]{srcschema, srctable});
|
| | | Statement stmtSrc = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
| | |
|
| | | stmtSrc.setFetchSize(FETCHSIZE);
|
| | | ResultSet rsSrc = stmtSrc.executeQuery(fetchSrcStmt);
|
| | | int igdsMetaType = rsSrc.getMetaData().getColumnType(1);
|
| | | while (rsSrc.next()) {
|
| | | if (isProfileMode()) {
|
| | | markQueryTime();
|
| | | }
|
| | |
|
| | | byte[] raw = null;
|
| | | if (igdsMetaType == Types.BLOB) {
|
| | | BLOB blob = (BLOB) rsSrc.getBlob(1);
|
| | |
|
| | | try {
|
| | | raw = getBytesFromBLOB(blob);
|
| | | } catch (BufferOverflowException e) {
|
| | | logger.warn("Wrong Element Structure-", e);
|
| | | } finally {
|
| | | // blob.close();
|
| | | }
|
| | | } else {
|
| | | raw = rsSrc.getBytes(1);
|
| | | }
|
| | |
|
| | | try {
|
| | | if (raw != null) {
|
| | | Element element = fetchBinaryElement(raw);
|
| | | if (isProfileMode()) {
|
| | | accumulateQueryTime();
|
| | | }
|
| | | jobContext.putFeatureCollection(element);
|
| | | } else {
|
| | | if (isProfileMode()) {
|
| | | accumulateQueryTime();
|
| | | }
|
| | | }
|
| | | } catch (Dgn7fileException e) {
|
| | | logger.warn("Dgn7Exception", e);
|
| | | }
|
| | | }
|
| | |
|
| | | JDBCUtils.close(rsSrc);
|
| | | JDBCUtils.close(stmtSrc);
|
| | | }
|
| | |
|
| | | protected void queryRawElement(OracleConvertEdbGeoJobContext jobContext,
|
| | | String srcschema, String srctable) throws SQLException {
|
| | | Connection connection = jobContext.getOracleConnection();
|
| | | String fetchDestStmtFmt = "SELECT ELEMENT FROM \"%s\".\"%s\" ORDER BY ROWID";
|
| | | PrintfFormat spf = new PrintfFormat(fetchDestStmtFmt);
|
| | | String fetchDestStmt = spf.sprintf(new Object[]{srcschema, srctable});
|
| | | Statement stmtDest = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
| | |
|
| | | stmtDest.setFetchSize(FETCHSIZE);
|
| | | ResultSet rsDest = stmtDest.executeQuery(fetchDestStmt);
|
| | |
|
| | | try {
|
| | | while (rsDest.next()) {
|
| | | ARRAY rawsValue = ((OracleResultSet) rsDest).getARRAY(1);
|
| | | long[] rawData = rawsValue.getLongArray();
|
| | | byte[] comparessedValue;
|
| | |
|
| | | /*
|
| | | if (dataMode == TransferTask.DataMode.Normal)
|
| | | {
|
| | | comparessedValue = BinConverter.unmarshalByteArray(rawData, true);
|
| | | } else
|
| | | {
|
| | | comparessedValue = BinConverter.unmarshalCompactByteArray(rawData);
|
| | | }
|
| | | */
|
| | | comparessedValue = BinConverter.unmarshalByteArray(rawData, true);
|
| | |
|
| | | byte[] rawDest = ByteArrayCompressor.decompressByteArray(comparessedValue);
|
| | |
|
| | | try {
|
| | | Element element = fetchBinaryElement(rawDest);
|
| | | jobContext.putFeatureCollection(element);
|
| | | } catch (Dgn7fileException e) {
|
| | | logger.warn("Dgn7Exception:" + e.getMessage(), e);
|
| | | }
|
| | | }
|
| | | } finally {
|
| | | JDBCUtils.close(rsDest);
|
| | | JDBCUtils.close(stmtDest);
|
| | | }
|
| | | }
|
| | |
|
| | | // Binary to Element
|
| | | private Element fetchBinaryElement(byte[] raws) throws Dgn7fileException {
|
| | | ByteBuffer buffer = ByteBuffer.wrap(raws);
|
| | | buffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | short signature = buffer.getShort();
|
| | |
|
| | | // byte type = (byte) (buffer.get() & 0x7f);
|
| | | byte type = (byte) ((signature >>> 8) & 0x007f);
|
| | |
|
| | | // silly Bentley say contentLength is in 2-byte words
|
| | | // and ByteByffer uses raws.
|
| | | // track the record location
|
| | | int elementLength = (buffer.getShort() * 2) + 4;
|
| | | ElementType recordType = ElementType.forID(type);
|
| | | IElementHandler handler;
|
| | |
|
| | | handler = recordType.getElementHandler();
|
| | |
|
| | | Element dgnElement = (Element) handler.read(buffer, signature, elementLength);
|
| | | if (recordType.isComplexElement() && (elementLength < raws.length)) {
|
| | | int offset = elementLength;
|
| | | while (offset < (raws.length - 4)) {
|
| | | buffer.position(offset);
|
| | | signature = buffer.getShort();
|
| | | type = (byte) ((signature >>> 8) & 0x007f);
|
| | | elementLength = (buffer.getShort() * 2) + 4;
|
| | | if (raws.length < (offset + elementLength)) {
|
| | | logger.debug("Length not match:" + offset + ":" + buffer.position() + ":" + buffer.limit());
|
| | | break;
|
| | | }
|
| | | recordType = ElementType.forID(type);
|
| | | handler = recordType.getElementHandler();
|
| | | if (handler != null) {
|
| | | Element subElement = (Element) handler.read(buffer, signature, elementLength);
|
| | | ((ComplexElement) dgnElement).add(subElement);
|
| | | offset += elementLength;
|
| | | } else {
|
| | | byte[] remain = new byte[buffer.remaining()];
|
| | | System.arraycopy(raws, offset, remain, 0, buffer.remaining());
|
| | | for (int i = 0; i < remain.length; i++) {
|
| | | if (remain[i] != 0) {
|
| | | logger.info("fetch element has some error. index=" + (offset + i) + ":value=" + remain[i]);
|
| | | }
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return dgnElement;
|
| | | }
|
| | |
|
| | | /**
|
| | | * �����ഫ�����ɪ��u�@
|
| | | *
|
| | | * @param context �u�@��������
|
| | | * @throws org.quartz.JobExecutionException
|
| | | * exception
|
| | | */
|
| | | private void convertIndexDesignFile(JobExecutionContext context, String targetSchemaName) throws JobExecutionException {
|
| | | File indexDir = new File(getDataPath(), INDEXPATHNAME);
|
| | | if (!indexDir.exists()) {
|
| | | logger.info("index dir=" + indexDir + " not exist.");
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!indexDir.isDirectory()) {
|
| | | logger.info("index dir=" + indexDir + " is not a directory.");
|
| | | }
|
| | |
|
| | | List<File> dgnFiles = FileUtils.recurseDir(indexDir, new FileFilter() {
|
| | | public boolean accept(File pathname) {
|
| | | return pathname.isDirectory() || pathname.getName().toLowerCase().endsWith("dgn");
|
| | | }
|
| | | });
|
| | |
|
| | | for (File dgnFile : dgnFiles) {
|
| | | if (dgnFile.isDirectory()) continue;
|
| | | IndexDgnConvertEdbGeoJobContext convertContext =
|
| | | new IndexDgnConvertEdbGeoJobContext(getDataPath(), getTargetDataStore(), targetSchemaName,
|
| | | isProfileMode(), isTransformed());
|
| | | logger.info("--- start index dgnfile-" + dgnFile.toString() + " ---");
|
| | | FileInputStream fs = null;
|
| | | FileChannel fc = null;
|
| | | Dgn7fileReader reader = null;
|
| | | try {
|
| | | convertContext.clearOutputDatabase();
|
| | | convertContext.setExecutionContext(context);
|
| | | String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.separator);
|
| | | convertContext.setFilename(dgnPaths[dgnPaths.length - 1]);
|
| | | convertContext.startTransaction();
|
| | |
|
| | | fs = new FileInputStream(dgnFile);
|
| | | fc = fs.getChannel();
|
| | | reader = new Dgn7fileReader(fc, new Lock());
|
| | | convertContext.setReader(reader);
|
| | |
|
| | | scanIndexDgnElement(convertContext);
|
| | |
|
| | | convertContext.commitTransaction();
|
| | | convertContext.closeFeatureWriter();
|
| | |
|
| | | System.gc();
|
| | | System.runFinalization();
|
| | | } catch (FileNotFoundException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (Dgn7fileException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (IOException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (IllegalAttributeException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (SchemaException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } finally {
|
| | | convertContext.closeFeatureWriter();
|
| | |
|
| | | if (reader != null) {
|
| | | try {
|
| | | reader.close();
|
| | | } catch (IOException e) {
|
| | | logger.warn(e.getMessage(), e);
|
| | | }
|
| | | }
|
| | |
|
| | | if (fs != null) {
|
| | | try {
|
| | | fs.close();
|
| | | } catch (IOException e) {
|
| | | logger.warn(e.getMessage(), e);
|
| | | }
|
| | | }
|
| | |
|
| | | if (isProfileMode()) {
|
| | | logger.warn("Profile-Current convertContext Process Cost-" +
|
| | | ((int) ((convertContext.getProcessTime()) / 60000.0)) + " min - " +
|
| | | (((int) ((convertContext.getProcessTime()) % 60000.0)) / 1000) + " sec");
|
| | | logger.warn("Profile-Current convertContext Update Cost-" +
|
| | | ((int) ((convertContext.getUpdateTime()) / 60000.0)) + " min - " +
|
| | | (((int) ((convertContext.getUpdateTime()) % 60000.0)) / 1000) + " sec");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | protected void scanIndexDgnElement(IndexDgnConvertEdbGeoJobContext convertContext)
|
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException {
|
| | | Dgn7fileReader reader = convertContext.getReader();
|
| | | int count = 0;
|
| | | Element lastComplex = null;
|
| | |
|
| | | while (reader.hasNext()) {
|
| | | if (isProfileMode()) markProcessTime();
|
| | | Element.FileRecord record = reader.nextElement();
|
| | | if (record.element() != null) {
|
| | | Element element = (Element) record.element();
|
| | | ElementType type = element.getElementType();
|
| | |
|
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) {
|
| | | if (lastComplex != null) {
|
| | | processIndexElement(lastComplex, convertContext);
|
| | | lastComplex = null;
|
| | | }
|
| | |
|
| | | processIndexElement(element, convertContext);
|
| | | } else if (element.isComponentElement()) {
|
| | | if (lastComplex != null) {
|
| | | ((ComplexElement) lastComplex).add(element);
|
| | | }
|
| | | } else if (type.isComplexElement()) {
|
| | | if (lastComplex != null) {
|
| | | processIndexElement(lastComplex, convertContext);
|
| | | }
|
| | | lastComplex = element;
|
| | | }
|
| | | }
|
| | | count++;
|
| | | }
|
| | |
|
| | | if (lastComplex != null) {
|
| | | processIndexElement(lastComplex, convertContext);
|
| | | }
|
| | | logger.debug("ElementRecord Count=" + count);
|
| | | }
|
| | |
|
| | | private void processIndexElement(Element element, IndexDgnConvertEdbGeoJobContext convertContext)
|
| | | throws IllegalAttributeException, SchemaException {
|
| | | //if (useTpclidText) {
|
| | | // if (element instanceof TextElement) {
|
| | | // convertContext.putFeatureCollection(element);
|
| | | // }
|
| | | //} else {
|
| | | // if (element instanceof ShapeElement) {
|
| | | convertContext.putFeatureCollection(element);
|
| | | // }
|
| | | //}
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * �����ഫ��L�]�p���ɪ��u�@
|
| | | *
|
| | | * @param context jobContext
|
| | | * @throws org.quartz.JobExecutionException
|
| | | * exception
|
| | | */
|
| | | private void convertOtherDesignFile(JobExecutionContext context, String targetSchemaName) throws JobExecutionException {
|
| | | File otherDir = new File(getDataPath(), OTHERPATHNAME);
|
| | | if (!otherDir.exists()) {
|
| | | logger.info("other dir=" + otherDir + " not exist.");
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!otherDir.isDirectory()) {
|
| | | logger.info("other dir=" + otherDir + " is not a directory.");
|
| | | }
|
| | |
|
| | | List<File> dgnFiles = FileUtils.recurseDir(otherDir, new FileFilter() {
|
| | | public boolean accept(File pathname) {
|
| | | return pathname.isDirectory() || pathname.getName().toLowerCase().endsWith("dgn");
|
| | | }
|
| | | });
|
| | |
|
| | | for (File dgnFile : dgnFiles) {
|
| | | if (dgnFile.isDirectory()) continue;
|
| | |
|
| | | GeneralDgnConvertEdbGeoJobContext convertContext =
|
| | | new GeneralDgnConvertEdbGeoJobContext(getDataPath(), getTargetDataStore(), targetSchemaName,
|
| | | isProfileMode(), isTransformed());
|
| | | logger.info("--- start other dgnfile-" + dgnFile.toString() + " ---");
|
| | | FileInputStream fs = null;
|
| | | FileChannel fc;
|
| | | Dgn7fileReader reader = null;
|
| | | try {
|
| | | convertContext.setExecutionContext(context);
|
| | | String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.separator);
|
| | | convertContext.setFilename(dgnPaths[dgnPaths.length - 1]);
|
| | | convertContext.startTransaction();
|
| | |
|
| | | fs = new FileInputStream(dgnFile);
|
| | | fc = fs.getChannel();
|
| | | reader = new Dgn7fileReader(fc, new Lock());
|
| | | convertContext.setReader(reader);
|
| | |
|
| | | scanOtherDgnElement(convertContext);
|
| | |
|
| | | convertContext.commitTransaction();
|
| | | convertContext.closeFeatureWriter();
|
| | |
|
| | | System.gc();
|
| | | System.runFinalization();
|
| | | } catch (FileNotFoundException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (Dgn7fileException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (IOException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (IllegalAttributeException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (SchemaException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } finally {
|
| | | convertContext.closeFeatureWriter();
|
| | |
|
| | | if (reader != null) {
|
| | | try {
|
| | | reader.close();
|
| | | } catch (IOException e) {
|
| | | logger.warn(e.getMessage(), e);
|
| | | }
|
| | | }
|
| | |
|
| | | if (fs != null) {
|
| | | try {
|
| | | fs.close();
|
| | | } catch (IOException e) {
|
| | | logger.warn(e.getMessage(), e);
|
| | | }
|
| | | }
|
| | |
|
| | | if (isProfileMode()) {
|
| | | logger.warn("Profile-Current convertContext Process Cost-" +
|
| | | ((int) ((convertContext.getProcessTime()) / 60000.0)) + " min - " +
|
| | | (((int) ((convertContext.getProcessTime()) % 60000.0)) / 1000) + " sec");
|
| | | logger.warn("Profile-Current convertContext Update Cost-" +
|
| | | ((int) ((convertContext.getUpdateTime()) / 60000.0)) + " min - " +
|
| | | (((int) ((convertContext.getUpdateTime()) % 60000.0)) / 1000) + " sec");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void scanOtherDgnElement(GeneralDgnConvertEdbGeoJobContext convertContext)
|
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException {
|
| | | Dgn7fileReader reader = convertContext.getReader();
|
| | | int count = 0;
|
| | | Element lastComplex = null;
|
| | | while (reader.hasNext()) {
|
| | | Element.FileRecord record = reader.nextElement();
|
| | | if (record.element() != null) {
|
| | | Element element = (Element) record.element();
|
| | | ElementType type = element.getElementType();
|
| | |
|
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) {
|
| | | if (lastComplex != null) {
|
| | | processOtherElement(lastComplex, convertContext);
|
| | | lastComplex = null;
|
| | | }
|
| | |
|
| | | processOtherElement(element, convertContext);
|
| | | } else if (element.isComponentElement()) {
|
| | | if (lastComplex != null) {
|
| | | ((ComplexElement) lastComplex).add(element);
|
| | | }
|
| | | } else if (type.isComplexElement()) {
|
| | | if (lastComplex != null) {
|
| | | processOtherElement(lastComplex, convertContext);
|
| | | }
|
| | | lastComplex = element;
|
| | | }
|
| | | }
|
| | | count++;
|
| | | }
|
| | |
|
| | | if (lastComplex != null) {
|
| | | processOtherElement(lastComplex, convertContext);
|
| | | }
|
| | | logger.debug("ElementRecord Count=" + count);
|
| | | }
|
| | |
|
| | | private void processOtherElement(Element element, GeneralDgnConvertEdbGeoJobContext convertContext)
|
| | | throws IllegalAttributeException, SchemaException {
|
| | | convertContext.putFeatureCollection(element);
|
| | | }
|
| | |
|
| | | private void clearOutputDatabase() {
|
| | | /*
|
| | | File outDataPath = new File(getDataPath(), OracleConvertEdbGeoJobContext.SHPOUTPATH);
|
| | | if (outDataPath.exists() && outDataPath.isDirectory())
|
| | | {
|
| | | deleteFilesInPath(outDataPath);
|
| | | }
|
| | | outDataPath = new File(getDataPath(), IndexDgnConvertShpJobContext.SHPOUTPATH);
|
| | | if (outDataPath.exists() && outDataPath.isDirectory())
|
| | | {
|
| | | deleteFilesInPath(outDataPath);
|
| | | }
|
| | | outDataPath = new File(getDataPath(), GeneralDgnConvertShpJobContext.SHPOUTPATH);
|
| | | if (outDataPath.exists() && outDataPath.isDirectory())
|
| | | {
|
| | | deleteFilesInPath(outDataPath);
|
| | | }
|
| | | */
|
| | | }
|
| | |
|
| | | private void deleteFilesInPath(File outDataPath) {
|
| | | deleteFilesInPath(outDataPath, true);
|
| | | }
|
| | |
|
| | | private void deleteFilesInPath(File outDataPath, boolean removeSubDir) {
|
| | | if (!outDataPath.isDirectory()) {
|
| | | return;
|
| | | }
|
| | | File[] files = outDataPath.listFiles();
|
| | | for (File file : files) {
|
| | | if (file.isFile()) {
|
| | | if (!file.delete()) {
|
| | | logger.info("Cannot delete file-" + file.toString());
|
| | | }
|
| | | } else if (file.isDirectory()) {
|
| | | deleteFilesInPath(file, removeSubDir);
|
| | | if (removeSubDir) {
|
| | | if (file.delete()) {
|
| | | logger.info("Cannot delete dir-" + file.toString());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void convertFeatureDesignFile(JobExecutionContext context, String targetSchemaName) throws JobExecutionException {
|
| | | File elminDir = new File(getDataPath(), "elmin");
|
| | | if (!elminDir.exists()) {
|
| | | logger.info("elmin dir=" + elminDir + " not exist.");
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!elminDir.isDirectory()) {
|
| | | logger.info("elmin dir=" + elminDir + " is not a directory.");
|
| | | }
|
| | |
|
| | | File[] dgnFiles = elminDir.listFiles(new FilenameFilter() {
|
| | | public boolean accept(File dir, String name) {
|
| | | return name.toLowerCase().endsWith(".dgn");
|
| | | }
|
| | | });
|
| | |
|
| | | for (File dgnFile : dgnFiles) {
|
| | | FeatureDgnConvertEdbGeoJobContext convertContext =
|
| | | new FeatureDgnConvertEdbGeoJobContext(getDataPath(), getTargetDataStore(), targetSchemaName, _filterPath,
|
| | | isProfileMode(), isTransformed());
|
| | | logger.info("--- start dgnfile-" + dgnFile.toString() + " ---");
|
| | | try {
|
| | | convertContext.setExecutionContext(context);
|
| | | String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.separator);
|
| | | convertContext.setFilename(dgnPaths[dgnPaths.length - 1]);
|
| | | convertContext.startTransaction();
|
| | |
|
| | | FileInputStream fs = new FileInputStream(dgnFile);
|
| | | FileChannel fc = fs.getChannel();
|
| | | Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock());
|
| | | convertContext.setReader(reader);
|
| | |
|
| | | scanFeatureDgnElement(convertContext);
|
| | |
|
| | | convertContext.commitTransaction();
|
| | | convertContext.closeFeatureWriter();
|
| | | System.gc();
|
| | | System.runFinalization();
|
| | | } catch (FileNotFoundException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (Dgn7fileException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (IOException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (IllegalAttributeException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } catch (SchemaException e) {
|
| | | convertContext.rollbackTransaction();
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | } finally {
|
| | | convertContext.closeFeatureWriter();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void scanFeatureDgnElement(FeatureDgnConvertEdbGeoJobContext convertContext)
|
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException {
|
| | | Dgn7fileReader reader = convertContext.getReader();
|
| | | int count = 0;
|
| | | Element lastComplex = null;
|
| | | while (reader.hasNext()) {
|
| | | Element.FileRecord record = reader.nextElement();
|
| | | if (record.element() != null) {
|
| | | Element element = (Element) record.element();
|
| | | ElementType type = element.getElementType();
|
| | |
|
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) {
|
| | | if (lastComplex != null) {
|
| | | processFeatureElement(lastComplex, convertContext);
|
| | | lastComplex = null;
|
| | | }
|
| | |
|
| | | processFeatureElement(element, convertContext);
|
| | | } else if (element.isComponentElement()) {
|
| | | if (lastComplex != null) {
|
| | | ((ComplexElement) lastComplex).add(element);
|
| | | }
|
| | | } else if (type.isComplexElement()) {
|
| | | if (lastComplex != null) {
|
| | | processFeatureElement(lastComplex, convertContext);
|
| | | }
|
| | | lastComplex = element;
|
| | | }
|
| | | }
|
| | | count++;
|
| | | }
|
| | |
|
| | | if (lastComplex != null) {
|
| | | processFeatureElement(lastComplex, convertContext);
|
| | | }
|
| | | logger.debug("ElementRecord Count=" + count);
|
| | | }
|
| | |
|
| | | private void processFeatureElement(Element element, FeatureDgnConvertEdbGeoJobContext convertContext)
|
| | | throws IllegalAttributeException, SchemaException {
|
| | | convertContext.putFeatureCollection(element);
|
| | | }
|
| | |
|
| | | private void createDummyFeatureFile(JobExecutionContext context) throws JobExecutionException {
|
| | | /*
|
| | | DummyFeatureConvertShpJobContext convertContext = new DummyFeatureConvertShpJobContext(getDataPath(), _filterPath);
|
| | | try {
|
| | | convertContext.startTransaction();
|
| | | convertContext.commitTransaction();
|
| | | convertContext.closeFeatureWriter();
|
| | | } catch (IOException e)
|
| | | {
|
| | | logger.warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | }
|
| | | */
|
| | | }
|
| | |
|
| | | public DataStore getTargetDataStore() {
|
| | | return targetDataStore;
|
| | | }
|
| | |
|
| | | protected void createTargetDataStore() throws JobExecutionException {
|
| | | if (targetDataStore != null) {
|
| | | targetDataStore.dispose();
|
| | | targetDataStore = null;
|
| | | }
|
| | |
|
| | | /*
|
| | | if (!isDriverFound())
|
| | | {
|
| | | throw new JobExecutionException("Oracle JDBC Driver not found.-" + JDBC_DRIVER);
|
| | | }
|
| | | */
|
| | |
|
| | | if (!edbProperties.containsKey(PostgisDataStoreFactory.MAXCONN.key)) {
|
| | | edbProperties.put(PostgisDataStoreFactory.MAXCONN.key, "5");
|
| | | }
|
| | |
|
| | | if (!edbProperties.containsKey(PostgisDataStoreFactory.MINCONN.key)) {
|
| | | edbProperties.put(PostgisDataStoreFactory.MINCONN.key, "1");
|
| | | }
|
| | |
|
| | | if (!edbProperties.containsKey(PostgisDataStoreFactory.WKBENABLED.key)) {
|
| | | edbProperties.put(PostgisDataStoreFactory.WKBENABLED.key, "true");
|
| | | }
|
| | |
|
| | | if (!dataStoreFactory.canProcess(edbProperties)) {
|
| | | getLogger().warn("cannot process properties-");
|
| | | throw new JobExecutionException("cannot process properties-");
|
| | | }
|
| | | try {
|
| | | targetDataStore = (JDBCDataStore) dataStoreFactory.createDataStore(edbProperties);
|
| | | } catch (IOException e) {
|
| | | getLogger().warn(e.getMessage(), e);
|
| | | throw new JobExecutionException(e.getMessage(), e);
|
| | | }
|
| | | }
|
| | |
|
| | | protected void disconnect() {
|
| | | super.disconnect();
|
| | | if (targetDataStore != null) {
|
| | | targetDataStore.dispose();
|
| | | targetDataStore = null;
|
| | | }
|
| | | }
|
| | |
|
| | | private String determineTargetSchemaName() throws IOException {
|
| | | if (targetDataStore == null) return null;
|
| | | Connection connection = null;
|
| | | Statement stmt = null;
|
| | | ResultSet rs = null;
|
| | | String targetSchema = null;
|
| | | boolean needCreate = false;
|
| | | try {
|
| | | connection = targetDataStore.getConnection(Transaction.AUTO_COMMIT);
|
| | | rs = connection.getMetaData().getTables(null, _edbSchema, DataReposVersionManager.XGVERSIONTABLE_NAME, new String[]{"TABLE"});
|
| | | if (!rs.next()) needCreate = true;
|
| | | rs.close();
|
| | | rs = null;
|
| | |
|
| | | stmt = connection.createStatement();
|
| | | stmt.execute("SET edb_redwood_date TO OFF");
|
| | | stmt.execute("SET edb_redwood_strings TO OFF");
|
| | | // stmt.execute("SET edb_stmt_level_tx TO OFF");
|
| | | stmt.close();
|
| | |
|
| | | if (needCreate)
|
| | | createXGeosVersionTable(connection, _edbSchema);
|
| | |
|
| | | StringBuilder sbSQL = new StringBuilder("SELECT ");
|
| | | sbSQL.append("vsschema, vsstatus FROM ");
|
| | | sbSQL.append(encodeSchemaTableName(_edbSchema, DataReposVersionManager.XGVERSIONTABLE_NAME)).append(' ');
|
| | | sbSQL.append("ORDER BY vsid");
|
| | | stmt = connection.createStatement();
|
| | | rs = stmt.executeQuery(sbSQL.toString());
|
| | | ArrayList<Object[]> tmpSchemas = new ArrayList<Object[]>();
|
| | | int i = 0;
|
| | | int current = -1;
|
| | | while (rs.next()) {
|
| | | Object[] values = new Object[2];
|
| | | values[0] = rs.getString("vsschema");
|
| | | values[1] = rs.getShort("vsstatus");
|
| | | tmpSchemas.add(values);
|
| | | if ((((Short) values[1]) & DataReposVersionManager.VSSTATUS_USING) != 0) {
|
| | | current = i;
|
| | | }
|
| | | i++;
|
| | | }
|
| | |
|
| | | if (current == -1) {
|
| | | Object[] values = tmpSchemas.get(0);
|
| | | targetSchema = (String) values[0];
|
| | | } else if (current < (tmpSchemas.size() - 1)) {
|
| | | Object[] values = tmpSchemas.get(current + 1);
|
| | | targetSchema = (String) values[0];
|
| | | } else {
|
| | | Object[] values = tmpSchemas.get(0);
|
| | | targetSchema = (String) values[0];
|
| | | }
|
| | |
|
| | | sbSQL = new StringBuilder("UPDATE ");
|
| | | sbSQL.append(encodeSchemaTableName(_edbSchema, DataReposVersionManager.XGVERSIONTABLE_NAME)).append(' ');
|
| | | sbSQL.append(" SET vsstatus = ");
|
| | | sbSQL.append(DataReposVersionManager.VSSTATUS_COVERT);
|
| | | sbSQL.append(" WHERE vsschema = '");
|
| | | sbSQL.append(targetSchema).append("'");
|
| | | int count = stmt.executeUpdate(sbSQL.toString());
|
| | | if (count != 1) {
|
| | | logger.info("update status for " + targetSchema + " update result count="
|
| | | + count);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | logger.warn(e.getMessage(), e);
|
| | | } finally {
|
| | | JDBCUtils.close(rs);
|
| | | JDBCUtils.close(stmt);
|
| | | JDBCUtils.close(connection, Transaction.AUTO_COMMIT, null);
|
| | | }
|
| | | return targetSchema;
|
| | | }
|
| | |
|
| | | public String encodeSchemaTableName(String schemaName, String tableName) {
|
| | | return "\"" + schemaName + "\".\"" + tableName + "\"";
|
| | | }
|
| | |
|
| | | private void createXGeosVersionTable(Connection connection, String pgSchema) throws SQLException {
|
| | | Statement stmt = null;
|
| | | StringBuilder sql = new StringBuilder("CREATE TABLE ");
|
| | | sql.append(encodeSchemaTableName(pgSchema, DataReposVersionManager.XGVERSIONTABLE_NAME));
|
| | | sql.append(" ( vsid serial PRIMARY KEY, ");
|
| | | sql.append(" vsschema character varying(64) NOT NULL, ");
|
| | | sql.append(" vsstatus smallint NOT NULL, ");
|
| | | sql.append(" vstimestamp timestamp with time zone ) ");
|
| | | try {
|
| | | stmt = connection.createStatement();
|
| | | stmt.executeUpdate(sql.toString());
|
| | |
|
| | | sql = new StringBuilder("ALTER TABLE ");
|
| | | sql.append(encodeSchemaTableName(pgSchema, DataReposVersionManager.XGVERSIONTABLE_NAME));
|
| | | sql.append(" OWNER TO ").append(_edbUsername);
|
| | | stmt.executeUpdate(sql.toString());
|
| | |
|
| | | sql = new StringBuilder("GRANT ALL ON TABLE ");
|
| | | sql.append(encodeSchemaTableName(pgSchema, DataReposVersionManager.XGVERSIONTABLE_NAME));
|
| | | sql.append(" TO public");
|
| | | stmt.executeUpdate(sql.toString());
|
| | |
|
| | | for (String schemaName : DataReposVersionManager.DEFAULTXGVERSIONSCHEMA_NAMES) {
|
| | | sql = new StringBuilder("INSERT INTO ");
|
| | | sql.append(encodeSchemaTableName(pgSchema, DataReposVersionManager.XGVERSIONTABLE_NAME));
|
| | | sql.append(" (vsschema, vsstatus) VALUES ('");
|
| | | sql.append(schemaName).append("', ");
|
| | | sql.append(DataReposVersionManager.VSSTATUS_AVAILABLE).append(" )");
|
| | | stmt.executeUpdate(sql.toString());
|
| | |
|
| | | createIfNotExistNewSchema(connection, schemaName);
|
| | | }
|
| | |
|
| | | } finally {
|
| | | if (stmt != null) stmt.close();
|
| | | }
|
| | | }
|
| | |
|
| | | private void updateRepoStatusToReady(String targetSchema) {
|
| | | if (targetDataStore == null) return;
|
| | | Connection connection = null;
|
| | | Statement stmt = null;
|
| | | ResultSet rs = null;
|
| | | boolean needCreate = false;
|
| | | try {
|
| | | StringBuilder sbSQL = new StringBuilder("UPDATE ");
|
| | | sbSQL.append(encodeSchemaTableName(_edbSchema, DataReposVersionManager.XGVERSIONTABLE_NAME)).append(' ');
|
| | | sbSQL.append(" SET vsstatus = ");
|
| | | sbSQL.append(DataReposVersionManager.VSSTATUS_READY);
|
| | | sbSQL.append(" , vstimestamp = CURRENT_TIMESTAMP WHERE vsschema = '");
|
| | | sbSQL.append(targetSchema).append("'");
|
| | |
|
| | | connection = targetDataStore.getConnection(Transaction.AUTO_COMMIT);
|
| | | stmt = connection.createStatement();
|
| | | int count = stmt.executeUpdate(sbSQL.toString());
|
| | | if (count != 1) {
|
| | | logger.info("update status for " + targetSchema + " update result count="
|
| | | + count);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | logger.warn(e.getMessage(), e);
|
| | | } catch (IOException e) {
|
| | | logger.warn(e.getMessage(), e);
|
| | | } finally {
|
| | | JDBCUtils.close(rs);
|
| | | JDBCUtils.close(stmt);
|
| | | JDBCUtils.close(connection, Transaction.AUTO_COMMIT, null);
|
| | | }
|
| | | }
|
| | |
|
| | | private void createIfNotExistNewSchema(Connection connection, String s) throws SQLException {
|
| | | Statement stmt = null;
|
| | | ResultSet rs = null;
|
| | | try {
|
| | | /*
|
| | | rs = connection.getMetaData().getSchemas(null, s);
|
| | | if (rs.next()) return;
|
| | | rs.close();
|
| | | rs = null;
|
| | | */
|
| | |
|
| | | StringBuilder sbSQL = new StringBuilder("CREATE SCHEMA ");
|
| | | sbSQL.append(s).append(' ');
|
| | | sbSQL.append("AUTHORIZATION ").append(_edbUsername);
|
| | | stmt = connection.createStatement();
|
| | | stmt.executeUpdate(sbSQL.toString());
|
| | |
|
| | | sbSQL = new StringBuilder("GRANT ALL ON SCHEMA ");
|
| | | sbSQL.append(s).append(' ');
|
| | | sbSQL.append("TO public");
|
| | | stmt.executeUpdate(sbSQL.toString());
|
| | | } catch (SQLException e) {
|
| | | logger.info("create schema:" + s + " has exception.");
|
| | | logger.info(e.getMessage(), e);
|
| | | } finally {
|
| | | if (rs != null) rs.close();
|
| | | if (stmt != null) stmt.close();
|
| | | }
|
| | | }
|
| | |
|
| | | public final void accumulateQueryTime() {
|
| | | queryTime += System.currentTimeMillis() - queryTimeStart;
|
| | | }
|
| | |
|
| | | public long getQueryTime() {
|
| | | return queryTime;
|
| | | }
|
| | |
|
| | | public final void markQueryTime() {
|
| | | queryTimeStart = System.currentTimeMillis();
|
| | | }
|
| | |
|
| | | public final void resetQueryTime() {
|
| | | queryTime = 0;
|
| | | }
|
| | | }
|
| | |
| | | import java.io.FilenameFilter; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.nio.BufferOverflowException; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.nio.channels.FileChannel; |
| | | import java.sql.Connection; |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | import java.sql.Statement; |
| | | import java.sql.Types; |
| | | import java.sql.Connection; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.geotools.data.DataStore; |
| | | import org.geotools.data.mysql.MySQLDataStore; |
| | | import org.geotools.data.mysql.MySQLDataStoreFactory; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SchemaException; |
| | | import org.geotools.jdbc.JDBCDataStore; |
| | | import org.opengis.feature.IllegalAttributeException; |
| | | import org.quartz.JobDataMap; |
| | | import org.quartz.JobDetail; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | import oracle.jdbc.OracleConnection; |
| | | import oracle.jdbc.OracleResultSet; |
| | |
| | | import oracle.sql.BLOB; |
| | | |
| | | import com.ximple.eofms.jobs.context.AbstractOracleJobContext; |
| | | import com.ximple.eofms.jobs.context.mysql.OracleConvertMySQLJobContext; |
| | | import com.ximple.eofms.jobs.context.mysql.IndexDgnConvertMySQLJobContext; |
| | | import com.ximple.eofms.jobs.context.mysql.GeneralDgnConvertMySQLJobContext; |
| | | import com.ximple.eofms.jobs.context.mysql.FeatureDgnConvertMySQLJobContext; |
| | | import com.ximple.eofms.jobs.context.mysql.GeneralDgnConvertMySQLJobContext; |
| | | import com.ximple.eofms.jobs.context.mysql.IndexDgnConvertMySQLJobContext; |
| | | import com.ximple.eofms.jobs.context.mysql.OracleConvertMySQLJobContext; |
| | | import com.ximple.eofms.util.BinConverter; |
| | | import com.ximple.eofms.util.ByteArrayCompressor; |
| | | import com.ximple.eofms.util.StringUtils; |
| | |
| | | import com.ximple.io.dgn7.TextElement; |
| | | import com.ximple.util.PrintfFormat; |
| | | |
| | | public class OracleConvertDgn2MySQLJob extends AbstractOracleDatabaseJob |
| | | { |
| | | public class OracleConvertDgn2MySQLJob extends AbstractOracleDatabaseJob { |
| | | final static Log logger = LogFactory.getLog(OracleConvertDgn2PostGISJob.class); |
| | | |
| | | private static final String MYHOST = "MYHOST"; |
| | |
| | | private static final int FETCHSIZE = 30; |
| | | private static final int COMMITSIZE = 20; |
| | | |
| | | class Pair |
| | | { |
| | | class Pair { |
| | | Object first; |
| | | Object second; |
| | | |
| | | public Pair(Object first, Object second) |
| | | { |
| | | public Pair(Object first, Object second) { |
| | | this.first = first; |
| | | this.second = second; |
| | | } |
| | |
| | | |
| | | protected static MySQLDataStoreFactory dataStoreFactory = new MySQLDataStoreFactory(); |
| | | |
| | | GeometryFactory _geomFactory = new GeometryFactory(); |
| | | protected String _myHost; |
| | | protected String _myDatabase; |
| | | protected String _myPort; |
| | |
| | | protected String _myUseWKB; |
| | | |
| | | protected Map<String, String> myProperties; |
| | | protected MySQLDataStore targetDataStore; |
| | | protected JDBCDataStore targetDataStore; |
| | | |
| | | public Log getLogger() |
| | | { |
| | | public Log getLogger() { |
| | | return logger; |
| | | } |
| | | |
| | | protected AbstractOracleJobContext prepareJobContext(String targetSchemaName, String filterPath) |
| | | { |
| | | return new OracleConvertMySQLJobContext(getDataPath(), getTargetDataStore(), filterPath); |
| | | protected AbstractOracleJobContext prepareJobContext(String targetSchemaName, String filterPath, boolean profileMode, |
| | | boolean useTransform) { |
| | | return new OracleConvertMySQLJobContext(getDataPath(), getTargetDataStore(), filterPath, profileMode, |
| | | useTransform); |
| | | } |
| | | |
| | | protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException |
| | | { |
| | | protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException { |
| | | super.extractJobConfiguration(jobDetail); |
| | | JobDataMap dataMap = jobDetail.getJobDataMap(); |
| | | _myHost = dataMap.getString(MYHOST); |
| | |
| | | logger.info("USEWKB=" + _myUseWKB); |
| | | */ |
| | | |
| | | if (_myHost == null) |
| | | { |
| | | if (_myHost == null) { |
| | | logger.warn("MYHOST is null"); |
| | | throw new JobExecutionException("Unknown PostGIS host."); |
| | | } |
| | | if (_myDatabase == null) |
| | | { |
| | | if (_myDatabase == null) { |
| | | logger.warn("PGDATABASE is null"); |
| | | throw new JobExecutionException("Unknown PostGIS database."); |
| | | } |
| | | if (_myPort == null) |
| | | { |
| | | if (_myPort == null) { |
| | | logger.warn("MYPORT is null"); |
| | | throw new JobExecutionException("Unknown PostGIS port."); |
| | | } |
| | | if (_mySchema == null) |
| | | { |
| | | if (_mySchema == null) { |
| | | logger.warn("MYSCHEMA is null"); |
| | | throw new JobExecutionException("Unknown PostGIS schema."); |
| | | } |
| | | if (_myUsername == null) |
| | | { |
| | | if (_myUsername == null) { |
| | | logger.warn("PGUSERNAME is null"); |
| | | throw new JobExecutionException("Unknown PostGIS username."); |
| | | } |
| | | if (_myPassword == null) |
| | | { |
| | | if (_myPassword == null) { |
| | | logger.warn("PGPASSWORD is null"); |
| | | throw new JobExecutionException("Unknown PostGIS password."); |
| | | } |
| | |
| | | myProperties = remote; |
| | | } |
| | | |
| | | public void execute(JobExecutionContext context) throws JobExecutionException |
| | | { |
| | | public void execute(JobExecutionContext context) throws JobExecutionException { |
| | | // Every job has its own job detail |
| | | JobDetail jobDetail = context.getJobDetail(); |
| | | |
| | | // The name is defined in the job definition |
| | | String jobName = jobDetail.getName(); |
| | | String jobName = jobDetail.getKey().getName(); |
| | | String targetSchemaName = null; |
| | | |
| | | // Log the time the job started |
| | |
| | | extractJobConfiguration(jobDetail); |
| | | createSourceDataStore(); |
| | | createTargetDataStore(); |
| | | if (getSourceDataStore() == null) |
| | | { |
| | | if (getSourceDataStore() == null) { |
| | | logger.warn("Cannot connect source oracle database."); |
| | | throw new JobExecutionException("Cannot connect source oracle database."); |
| | | } |
| | | |
| | | if (getTargetDataStore() == null) |
| | | { |
| | | if (getTargetDataStore() == null) { |
| | | logger.warn("Cannot connect source postgreSQL database."); |
| | | throw new JobExecutionException("Cannot connect source postgreSQL database."); |
| | | } |
| | | |
| | | long t1 = System.currentTimeMillis(); |
| | | try |
| | | { |
| | | try { |
| | | logger.info("-- step:clearOutputDatabase --"); |
| | | clearOutputDatabase(); |
| | | boolean bFirst = isCopyConnectivityMode(); |
| | | if (checkConvertDB()) |
| | | { |
| | | if (checkConvertDB()) { |
| | | logger.info("-- step:convertOracleDB --"); |
| | | |
| | | for (String orgSchema : _orgSchema) |
| | | { |
| | | for (String orgSchema : _orgSchema) { |
| | | OracleConvertMySQLJobContext jobContext = |
| | | (OracleConvertMySQLJobContext) prepareJobContext(targetSchemaName, _filterPath); |
| | | (OracleConvertMySQLJobContext) prepareJobContext(targetSchemaName, _filterPath, |
| | | isProfileMode(), isTransformed()); |
| | | jobContext.setSourceDataStore(getSourceDataStore()); |
| | | // jobContext.setConvertElementIn(_convertElementIn); |
| | | jobContext.setElementLogging(checkElementLogging()); |
| | | jobContext.setExecutionContext(context); |
| | | |
| | | fetchTPData(jobContext); |
| | | logger.info("TPC DIST:" + jobContext.getDistId() + ":" + |
| | | ((jobContext.getDistName() == null) ? "NULL" : jobContext.getDistName())); |
| | | |
| | | if (bFirst) |
| | | copyConnectivity(jobContext); |
| | |
| | | } |
| | | } |
| | | |
| | | if (checkConvertFile()) |
| | | { |
| | | if (checkConvertFile()) { |
| | | logger.info("-- step:convertIndexDesignFile --"); |
| | | convertIndexDesignFile(context); |
| | | logger.info("-- step:convertOtherDesignFile --"); |
| | | convertOtherDesignFile(context); |
| | | } |
| | | |
| | | if (checkConvertElementIn()) |
| | | { |
| | | if (checkConvertElementIn()) { |
| | | logger.info("-- step:convertFeatureDesignFile --"); |
| | | convertFeatureDesignFile(context); |
| | | } |
| | | |
| | | if (checkCreateDummy()) |
| | | { |
| | | if (checkCreateDummy()) { |
| | | logger.info("-- step:createDummyFeatureFile --"); |
| | | createDummyFeatureFile(context); |
| | | } |
| | |
| | | // public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; |
| | | // SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); |
| | | logger.warn("use time = " + ((t2 - t1) / 60000.0) + " min"); |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException("Database error. " + e.getMessage(), e); |
| | | } catch (IOException ex) |
| | | { |
| | | } catch (IOException ex) { |
| | | logger.warn(ex.getMessage(), ex); |
| | | throw new JobExecutionException("IO error. " + ex.getMessage(), ex); |
| | | } |
| | | logger.warn(jobName + " end at " + new Date()); |
| | | } |
| | | |
| | | /** |
| | | * Connectivity½Æ»s¤@Óª©¥»¡A¦b¬d¸ß¹q¬y¤è¦V®É¥Î¨Ó¤ñ¹ïOMS¸ê®Æ®wªº¹q¾¹³s±µ©Ê(Connectivity) |
| | | * |
| | | * @param jobContext job context |
| | | * @throws SQLException sql exception |
| | | */ |
| | | private void copyConnectivity(OracleConvertMySQLJobContext jobContext) throws SQLException |
| | | { |
| | | Connection connection = jobContext.getOracleConnection(); |
| | | Statement stmt = connection.createStatement(); |
| | | stmt.execute(AbstractOracleJobContext.TRUNCATE_CONNECTIVITY_WEBCHECK); |
| | | stmt.execute(AbstractOracleJobContext.COPY_CONNECTIVITY_TO_WEBCHECK); |
| | | } |
| | | |
| | | private void exetcuteConvert(OracleConvertMySQLJobContext jobContext, |
| | | String querySchema, String dataPath) throws SQLException |
| | | { |
| | | String querySchema, String dataPath) throws SQLException { |
| | | int order = 0; |
| | | OrderedMap map = getBlobStorageList(jobContext.getOracleConnection(), querySchema, "SD$SPACENODES" |
| | | , null); |
| | |
| | | //jobContext.startTransaction(); |
| | | jobContext.setCurrentSchema(querySchema); |
| | | jobContext.getExecutionContext().put("ConvertDgn2PostGISJobProgress", 0); |
| | | for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext();) |
| | | { |
| | | for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext();) { |
| | | it.next(); |
| | | |
| | | Pair pair = (Pair) it.getValue(); |
| | |
| | | |
| | | order++; |
| | | |
| | | if (_testMode) |
| | | { |
| | | if (_testMode) { |
| | | if ((_testCount < 0) || (order >= _testCount)) |
| | | break; |
| | | } |
| | | |
| | | if ((order % COMMITSIZE) == 0) |
| | | { |
| | | if ((order % COMMITSIZE) == 0) { |
| | | // OracleConnection connection = jobContext.getOracleConnection(); |
| | | // connection.commitTransaction(); |
| | | jobContext.commitTransaction(); |
| | |
| | | } |
| | | |
| | | int now = order % step; |
| | | if (now != current) |
| | | { |
| | | if (now != current) { |
| | | current = now; |
| | | jobContext.getExecutionContext().put("ConvertDgn2PostGISJobProgress", current); |
| | | |
| | |
| | | } |
| | | |
| | | protected OrderedMap getBlobStorageList(Connection connection, String schemaSrc, String tableSrc, |
| | | OrderedMap orderedMap) throws SQLException |
| | | { |
| | | OrderedMap orderedMap) throws SQLException { |
| | | if (orderedMap == null) |
| | | orderedMap = new LinkedMap(99); |
| | | String fetchStmtFmt = "SELECT SNID, SPACETABLE FROM \"%s\".\"%s\""; |
| | |
| | | |
| | | stmt.setFetchSize(FETCHSIZE); |
| | | |
| | | try |
| | | { |
| | | try { |
| | | rs = stmt.executeQuery(fetchStmt); |
| | | int size = rs.getMetaData().getColumnCount(); |
| | | while (rs.next()) |
| | | { |
| | | while (rs.next()) { |
| | | Object[] values = new Object[size]; |
| | | |
| | | for (int i = 0; i < size; i++) |
| | | { |
| | | for (int i = 0; i < size; i++) { |
| | | values[i] = rs.getObject(i + 1); |
| | | } |
| | | |
| | |
| | | else |
| | | pair.first = name; |
| | | } |
| | | } catch (SQLException e) |
| | | { |
| | | } catch (SQLException e) { |
| | | logger.error(e.toString(), e); |
| | | logger.error("stmt=" + fetchStmt); |
| | | throw e; |
| | | } finally |
| | | { |
| | | } finally { |
| | | if (rs != null) rs.close(); |
| | | stmt.close(); |
| | | } |
| | |
| | | } |
| | | |
| | | protected OrderedMap getRawFormatStorageList(OracleConnection connection, String schemaSrc, String tableSrc, |
| | | OrderedMap orderedMap) throws SQLException |
| | | { |
| | | OrderedMap orderedMap) throws SQLException { |
| | | if (orderedMap == null) |
| | | orderedMap = new LinkedMap(99); |
| | | String fetchStmtFmt = "SELECT RNID, SPACETABLE FROM \"%s\".\"%s\""; |
| | |
| | | |
| | | ResultSet rs = stmt.executeQuery(fetchStmt); |
| | | int size = rs.getMetaData().getColumnCount(); |
| | | while (rs.next()) |
| | | { |
| | | while (rs.next()) { |
| | | Object[] values = new Object[size]; |
| | | |
| | | for (int i = 0; i < size; i++) |
| | | { |
| | | for (int i = 0; i < size; i++) { |
| | | values[i] = rs.getObject(i + 1); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | protected void queryIgsetElement(OracleConvertMySQLJobContext jobContext, |
| | | String srcschema, String srctable) throws SQLException |
| | | { |
| | | String srcschema, String srctable) throws SQLException { |
| | | Connection connection = jobContext.getOracleConnection(); |
| | | String fetchSrcStmtFmt = "SELECT IGDSELM FROM \"%s\".\"%s\" ORDER BY ROWID"; |
| | | PrintfFormat spf = new PrintfFormat(fetchSrcStmtFmt); |
| | |
| | | |
| | | ResultSet rsSrc = stmtSrc.executeQuery(fetchSrcStmt); |
| | | int igdsMetaType = rsSrc.getMetaData().getColumnType(1); |
| | | while (rsSrc.next()) |
| | | { |
| | | byte[] raw; |
| | | while (rsSrc.next()) { |
| | | byte[] raw = null; |
| | | |
| | | if (igdsMetaType == Types.BLOB) |
| | | { |
| | | if (igdsMetaType == Types.BLOB) { |
| | | BLOB blob = (BLOB) rsSrc.getBlob(1); |
| | | |
| | | try { |
| | | raw = getBytesFromBLOB(blob); |
| | | blob.close(); |
| | | } else |
| | | { |
| | | } catch (BufferOverflowException e) { |
| | | logger.warn("Wrong Element Structure-", e); |
| | | } finally { |
| | | // blob.close(); |
| | | } |
| | | } else { |
| | | raw = rsSrc.getBytes(1); |
| | | } |
| | | |
| | | try |
| | | { |
| | | try { |
| | | if (raw != null) { |
| | | Element element = fetchBinaryElement(raw); |
| | | jobContext.putFeatureCollection(element); |
| | | } catch (Dgn7fileException e) |
| | | { |
| | | } |
| | | } catch (Dgn7fileException e) { |
| | | logger.warn("Dgn7Exception", e); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | protected void queryRawElement(OracleConvertMySQLJobContext jobContext, |
| | | String srcschema, String srctable) throws SQLException |
| | | { |
| | | String srcschema, String srctable) throws SQLException { |
| | | Connection connection = jobContext.getOracleConnection(); |
| | | String fetchDestStmtFmt = "SELECT ELEMENT FROM \"%s\".\"%s\" ORDER BY ROWID"; |
| | | PrintfFormat spf = new PrintfFormat(fetchDestStmtFmt); |
| | |
| | | |
| | | ResultSet rsDest = stmtDest.executeQuery(fetchDestStmt); |
| | | |
| | | while (rsDest.next()) |
| | | { |
| | | while (rsDest.next()) { |
| | | ARRAY rawsValue = ((OracleResultSet) rsDest).getARRAY(1); |
| | | long[] rawData = rawsValue.getLongArray(); |
| | | byte[] comparessedValue; |
| | |
| | | byte[] rawDest = ByteArrayCompressor.decompressByteArray(comparessedValue); |
| | | |
| | | |
| | | try |
| | | { |
| | | try { |
| | | Element element = fetchBinaryElement(rawDest); |
| | | jobContext.putFeatureCollection(element); |
| | | } catch (Dgn7fileException e) |
| | | { |
| | | } catch (Dgn7fileException e) { |
| | | logger.warn("Dgn7Exception:" + e.getMessage(), e); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | // Binary to Element |
| | | private Element fetchBinaryElement(byte[] raws) throws Dgn7fileException |
| | | { |
| | | private Element fetchBinaryElement(byte[] raws) throws Dgn7fileException { |
| | | ByteBuffer buffer = ByteBuffer.wrap(raws); |
| | | buffer.order(ByteOrder.LITTLE_ENDIAN); |
| | | short signature = buffer.getShort(); |
| | |
| | | handler = recordType.getElementHandler(); |
| | | |
| | | Element dgnElement = (Element) handler.read(buffer, signature, elementLength); |
| | | if (recordType.isComplexElement() && (elementLength < raws.length)) |
| | | { |
| | | if (recordType.isComplexElement() && (elementLength < raws.length)) { |
| | | int offset = elementLength; |
| | | while (offset < (raws.length - 4)) |
| | | { |
| | | while (offset < (raws.length - 4)) { |
| | | buffer.position(offset); |
| | | signature = buffer.getShort(); |
| | | type = (byte) ((signature >>> 8) & 0x007f); |
| | | elementLength = (buffer.getShort() * 2) + 4; |
| | | if (raws.length < (offset + elementLength)) |
| | | { |
| | | if (raws.length < (offset + elementLength)) { |
| | | System.out.println("Length not match:" + offset + ":" + buffer.position() + ":" + buffer.limit()); |
| | | break; |
| | | } |
| | | recordType = ElementType.forID(type); |
| | | handler = recordType.getElementHandler(); |
| | | if (handler != null) |
| | | { |
| | | if (handler != null) { |
| | | Element subElement = (Element) handler.read(buffer, signature, elementLength); |
| | | ((ComplexElement) dgnElement).add(subElement); |
| | | offset += elementLength; |
| | | } else |
| | | { |
| | | } else { |
| | | byte[] remain = new byte[buffer.remaining()]; |
| | | System.arraycopy(raws, offset, remain, 0, buffer.remaining()); |
| | | for (int i = 0; i < remain.length; i++) |
| | | { |
| | | if (remain[i] != 0) |
| | | { |
| | | for (int i = 0; i < remain.length; i++) { |
| | | if (remain[i] != 0) { |
| | | logger.info("fetch element has some error. index=" + (offset + i) + ":value=" + remain[i]); |
| | | System.out.println("fetch element has some error. index=" + (offset + i) + ":value=" + remain[i]); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * °õ¦æÂà´«¯Á¤Þ¹ÏÀɪº¤u§@ |
| | | * �����ഫ�����ɪ��u�@ |
| | | * |
| | | * @param context ¤u§@°õ¦æÀô¹Ò |
| | | * @param context �u�@�������� |
| | | * @throws org.quartz.JobExecutionException |
| | | * exception |
| | | */ |
| | | private void convertIndexDesignFile(JobExecutionContext context) throws JobExecutionException |
| | | { |
| | | private void convertIndexDesignFile(JobExecutionContext context) throws JobExecutionException { |
| | | File indexDir = new File(getDataPath(), "index"); |
| | | if (!indexDir.exists()) |
| | | { |
| | | if (!indexDir.exists()) { |
| | | logger.info("index dir=" + indexDir + " not exist."); |
| | | return; |
| | | } |
| | | |
| | | if (!indexDir.isDirectory()) |
| | | { |
| | | if (!indexDir.isDirectory()) { |
| | | logger.info("index dir=" + indexDir + " is not a directory."); |
| | | } |
| | | |
| | | File[] dgnFiles = indexDir.listFiles(new FilenameFilter() |
| | | { |
| | | public boolean accept(File dir, String name) |
| | | { |
| | | File[] dgnFiles = indexDir.listFiles(new FilenameFilter() { |
| | | public boolean accept(File dir, String name) { |
| | | return name.toLowerCase().endsWith(".dgn"); |
| | | } |
| | | }); |
| | | |
| | | for (File dgnFile : dgnFiles) |
| | | { |
| | | for (File dgnFile : dgnFiles) { |
| | | IndexDgnConvertMySQLJobContext convertContext = |
| | | new IndexDgnConvertMySQLJobContext(getDataPath(), getTargetDataStore()); |
| | | new IndexDgnConvertMySQLJobContext(getDataPath(), getTargetDataStore(), isProfileMode(), |
| | | isTransformed()); |
| | | logger.debug("--- start dgnfile-" + dgnFile.toString() + " ---"); |
| | | try |
| | | { |
| | | try { |
| | | convertContext.setExecutionContext(context); |
| | | String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.separator); |
| | | convertContext.setFilename(dgnPaths[dgnPaths.length - 1]); |
| | |
| | | convertContext.closeFeatureWriter(); |
| | | System.gc(); |
| | | System.runFinalization(); |
| | | } catch (FileNotFoundException e) |
| | | { |
| | | } catch (FileNotFoundException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (Dgn7fileException e) |
| | | { |
| | | } catch (Dgn7fileException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IOException e) |
| | | { |
| | | } catch (IOException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | } catch (IllegalAttributeException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (SchemaException e) |
| | | { |
| | | } catch (SchemaException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | |
| | | } |
| | | |
| | | protected void scanIndexDgnElement(IndexDgnConvertMySQLJobContext convertContext) |
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException |
| | | { |
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException { |
| | | Dgn7fileReader reader = convertContext.getReader(); |
| | | int count = 0; |
| | | Element lastComplex = null; |
| | | while (reader.hasNext()) |
| | | { |
| | | Dgn7fileReader.Record record = reader.nextElement(); |
| | | if (record.element() != null) |
| | | { |
| | | while (reader.hasNext()) { |
| | | Element.FileRecord record = reader.nextElement(); |
| | | if (record.element() != null) { |
| | | Element element = (Element) record.element(); |
| | | ElementType type = element.getElementType(); |
| | | |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) { |
| | | if (lastComplex != null) { |
| | | processIndexElement(lastComplex, convertContext); |
| | | lastComplex = null; |
| | | } |
| | | |
| | | processIndexElement(element, convertContext); |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | } else if (element.isComponentElement()) { |
| | | if (lastComplex != null) { |
| | | ((ComplexElement) lastComplex).add(element); |
| | | } |
| | | } else if (type.isComplexElement()) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | } else if (type.isComplexElement()) { |
| | | if (lastComplex != null) { |
| | | processIndexElement(lastComplex, convertContext); |
| | | } |
| | | lastComplex = element; |
| | |
| | | count++; |
| | | } |
| | | |
| | | if (lastComplex != null) |
| | | { |
| | | if (lastComplex != null) { |
| | | processIndexElement(lastComplex, convertContext); |
| | | } |
| | | logger.debug("ElementRecord Count=" + count); |
| | | } |
| | | |
| | | private void processIndexElement(Element element, IndexDgnConvertMySQLJobContext convertContext) |
| | | throws IllegalAttributeException, SchemaException |
| | | { |
| | | if (element instanceof TextElement) |
| | | { |
| | | throws IllegalAttributeException, SchemaException { |
| | | if (element instanceof TextElement) { |
| | | convertContext.putFeatureCollection(element); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * °õ¦æÂà´«¨ä¥L³]p¹ÏÀɪº¤u§@ |
| | | * �����ഫ��L�]�p���ɪ��u�@ |
| | | * |
| | | * @param context jobContext |
| | | * @throws org.quartz.JobExecutionException |
| | | * exception |
| | | */ |
| | | private void convertOtherDesignFile(JobExecutionContext context) throws JobExecutionException |
| | | { |
| | | private void convertOtherDesignFile(JobExecutionContext context) throws JobExecutionException { |
| | | File otherDir = new File(getDataPath(), "other"); |
| | | if (!otherDir.exists()) |
| | | { |
| | | if (!otherDir.exists()) { |
| | | logger.info("other dir=" + otherDir + " not exist."); |
| | | return; |
| | | } |
| | | |
| | | if (!otherDir.isDirectory()) |
| | | { |
| | | if (!otherDir.isDirectory()) { |
| | | logger.info("other dir=" + otherDir + " is not a directory."); |
| | | } |
| | | |
| | | File[] dgnFiles = otherDir.listFiles(new FilenameFilter() |
| | | { |
| | | public boolean accept(File dir, String name) |
| | | { |
| | | File[] dgnFiles = otherDir.listFiles(new FilenameFilter() { |
| | | public boolean accept(File dir, String name) { |
| | | return name.toLowerCase().endsWith(".dgn"); |
| | | } |
| | | }); |
| | | |
| | | for (File dgnFile : dgnFiles) |
| | | { |
| | | for (File dgnFile : dgnFiles) { |
| | | GeneralDgnConvertMySQLJobContext convertContext = |
| | | new GeneralDgnConvertMySQLJobContext(getDataPath(), getTargetDataStore()); |
| | | new GeneralDgnConvertMySQLJobContext(getDataPath(), getTargetDataStore(), isProfileMode(), |
| | | isTransformed()); |
| | | logger.info("--- start dgnfile-" + dgnFile.toString() + " ---"); |
| | | try |
| | | { |
| | | try { |
| | | convertContext.setExecutionContext(context); |
| | | String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.separator); |
| | | convertContext.setFilename(dgnPaths[dgnPaths.length - 1]); |
| | |
| | | convertContext.closeFeatureWriter(); |
| | | System.gc(); |
| | | System.runFinalization(); |
| | | } catch (FileNotFoundException e) |
| | | { |
| | | } catch (FileNotFoundException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (Dgn7fileException e) |
| | | { |
| | | } catch (Dgn7fileException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IOException e) |
| | | { |
| | | } catch (IOException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | } catch (IllegalAttributeException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (SchemaException e) |
| | | { |
| | | } catch (SchemaException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | |
| | | } |
| | | |
| | | public void scanOtherDgnElement(GeneralDgnConvertMySQLJobContext convertContext) |
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException |
| | | { |
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException { |
| | | Dgn7fileReader reader = convertContext.getReader(); |
| | | int count = 0; |
| | | Element lastComplex = null; |
| | | while (reader.hasNext()) |
| | | { |
| | | Dgn7fileReader.Record record = reader.nextElement(); |
| | | if (record.element() != null) |
| | | { |
| | | while (reader.hasNext()) { |
| | | Element.FileRecord record = reader.nextElement(); |
| | | if (record.element() != null) { |
| | | Element element = (Element) record.element(); |
| | | ElementType type = element.getElementType(); |
| | | |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) { |
| | | if (lastComplex != null) { |
| | | processOtherElement(lastComplex, convertContext); |
| | | lastComplex = null; |
| | | } |
| | | |
| | | processOtherElement(element, convertContext); |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | } else if (element.isComponentElement()) { |
| | | if (lastComplex != null) { |
| | | ((ComplexElement) lastComplex).add(element); |
| | | } |
| | | } else if (type.isComplexElement()) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | } else if (type.isComplexElement()) { |
| | | if (lastComplex != null) { |
| | | processOtherElement(lastComplex, convertContext); |
| | | } |
| | | lastComplex = element; |
| | |
| | | count++; |
| | | } |
| | | |
| | | if (lastComplex != null) |
| | | { |
| | | if (lastComplex != null) { |
| | | processOtherElement(lastComplex, convertContext); |
| | | } |
| | | logger.debug("ElementRecord Count=" + count); |
| | | } |
| | | |
| | | private void processOtherElement(Element element, GeneralDgnConvertMySQLJobContext convertContext) |
| | | throws IllegalAttributeException, SchemaException |
| | | { |
| | | throws IllegalAttributeException, SchemaException { |
| | | convertContext.putFeatureCollection(element); |
| | | } |
| | | |
| | | private void clearOutputDatabase() |
| | | { |
| | | private void clearOutputDatabase() { |
| | | /* |
| | | File outDataPath = new File(getDataPath(), OracleConvertPostGISJobContext.SHPOUTPATH); |
| | | File outDataPath = new File(getDataPath(), OracleConvertEdbGeoJobContext.SHPOUTPATH); |
| | | if (outDataPath.exists() && outDataPath.isDirectory()) |
| | | { |
| | | deleteFilesInPath(outDataPath); |
| | |
| | | */ |
| | | } |
| | | |
| | | private void deleteFilesInPath(File outDataPath) |
| | | { |
| | | private void deleteFilesInPath(File outDataPath) { |
| | | deleteFilesInPath(outDataPath, true); |
| | | } |
| | | |
| | | private void deleteFilesInPath(File outDataPath, boolean removeSubDir) |
| | | { |
| | | if (!outDataPath.isDirectory()) |
| | | { |
| | | private void deleteFilesInPath(File outDataPath, boolean removeSubDir) { |
| | | if (!outDataPath.isDirectory()) { |
| | | return; |
| | | } |
| | | File[] files = outDataPath.listFiles(); |
| | | for (File file : files) |
| | | { |
| | | if (file.isFile()) |
| | | { |
| | | if (!file.delete()) |
| | | { |
| | | for (File file : files) { |
| | | if (file.isFile()) { |
| | | if (!file.delete()) { |
| | | logger.info("Cannot delete file-" + file.toString()); |
| | | } |
| | | } else if (file.isDirectory()) |
| | | { |
| | | } else if (file.isDirectory()) { |
| | | deleteFilesInPath(file, removeSubDir); |
| | | if (removeSubDir) |
| | | { |
| | | if (file.delete()) |
| | | { |
| | | if (removeSubDir) { |
| | | if (file.delete()) { |
| | | logger.info("Cannot delete dir-" + file.toString()); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private void convertFeatureDesignFile(JobExecutionContext context) throws JobExecutionException |
| | | { |
| | | private void convertFeatureDesignFile(JobExecutionContext context) throws JobExecutionException { |
| | | File elminDir = new File(getDataPath(), "elmin"); |
| | | if (!elminDir.exists()) |
| | | { |
| | | if (!elminDir.exists()) { |
| | | logger.info("elmin dir=" + elminDir + " not exist."); |
| | | return; |
| | | } |
| | | |
| | | if (!elminDir.isDirectory()) |
| | | { |
| | | if (!elminDir.isDirectory()) { |
| | | logger.info("elmin dir=" + elminDir + " is not a directory."); |
| | | } |
| | | |
| | | File[] dgnFiles = elminDir.listFiles(new FilenameFilter() |
| | | { |
| | | public boolean accept(File dir, String name) |
| | | { |
| | | File[] dgnFiles = elminDir.listFiles(new FilenameFilter() { |
| | | public boolean accept(File dir, String name) { |
| | | return name.toLowerCase().endsWith(".dgn"); |
| | | } |
| | | }); |
| | | |
| | | for (File dgnFile : dgnFiles) |
| | | { |
| | | for (File dgnFile : dgnFiles) { |
| | | FeatureDgnConvertMySQLJobContext convertContext = |
| | | new FeatureDgnConvertMySQLJobContext(getDataPath(), getTargetDataStore(), _filterPath); |
| | | new FeatureDgnConvertMySQLJobContext(getDataPath(), getTargetDataStore(), _filterPath, isProfileMode(), |
| | | isTransformed()); |
| | | logger.info("--- start dgnfile-" + dgnFile.toString() + " ---"); |
| | | try |
| | | { |
| | | try { |
| | | convertContext.setExecutionContext(context); |
| | | String dgnPaths[] = StringUtils.splitToArray(dgnFile.toString(), File.separator); |
| | | convertContext.setFilename(dgnPaths[dgnPaths.length - 1]); |
| | |
| | | convertContext.closeFeatureWriter(); |
| | | System.gc(); |
| | | System.runFinalization(); |
| | | } catch (FileNotFoundException e) |
| | | { |
| | | } catch (FileNotFoundException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (Dgn7fileException e) |
| | | { |
| | | } catch (Dgn7fileException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IOException e) |
| | | { |
| | | } catch (IOException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | } catch (IllegalAttributeException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } catch (SchemaException e) |
| | | { |
| | | } catch (SchemaException e) { |
| | | convertContext.rollbackTransaction(); |
| | | logger.warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | |
| | | } |
| | | |
| | | public void scanFeatureDgnElement(FeatureDgnConvertMySQLJobContext convertContext) |
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException |
| | | { |
| | | throws Dgn7fileException, IOException, IllegalAttributeException, SchemaException { |
| | | Dgn7fileReader reader = convertContext.getReader(); |
| | | int count = 0; |
| | | Element lastComplex = null; |
| | | while (reader.hasNext()) |
| | | { |
| | | Dgn7fileReader.Record record = reader.nextElement(); |
| | | if (record.element() != null) |
| | | { |
| | | while (reader.hasNext()) { |
| | | Element.FileRecord record = reader.nextElement(); |
| | | if (record.element() != null) { |
| | | Element element = (Element) record.element(); |
| | | ElementType type = element.getElementType(); |
| | | |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | if ((!type.isComplexElement()) && (!element.isComponentElement())) { |
| | | if (lastComplex != null) { |
| | | processFeatureElement(lastComplex, convertContext); |
| | | lastComplex = null; |
| | | } |
| | | |
| | | processFeatureElement(element, convertContext); |
| | | } else if (element.isComponentElement()) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | } else if (element.isComponentElement()) { |
| | | if (lastComplex != null) { |
| | | ((ComplexElement) lastComplex).add(element); |
| | | } |
| | | } else if (type.isComplexElement()) |
| | | { |
| | | if (lastComplex != null) |
| | | { |
| | | } else if (type.isComplexElement()) { |
| | | if (lastComplex != null) { |
| | | processFeatureElement(lastComplex, convertContext); |
| | | } |
| | | lastComplex = element; |
| | |
| | | count++; |
| | | } |
| | | |
| | | if (lastComplex != null) |
| | | { |
| | | if (lastComplex != null) { |
| | | processFeatureElement(lastComplex, convertContext); |
| | | } |
| | | logger.debug("ElementRecord Count=" + count); |
| | | } |
| | | |
| | | private void processFeatureElement(Element element, FeatureDgnConvertMySQLJobContext convertContext) |
| | | throws IllegalAttributeException, SchemaException |
| | | { |
| | | throws IllegalAttributeException, SchemaException { |
| | | convertContext.putFeatureCollection(element); |
| | | } |
| | | |
| | | private void createDummyFeatureFile(JobExecutionContext context) throws JobExecutionException |
| | | { |
| | | private void createDummyFeatureFile(JobExecutionContext context) throws JobExecutionException { |
| | | /* |
| | | DummyFeatureConvertShpJobContext convertContext = new DummyFeatureConvertShpJobContext(getDataPath(), _filterPath); |
| | | try { |
| | |
| | | */ |
| | | } |
| | | |
| | | public DataStore getTargetDataStore() |
| | | { |
| | | public DataStore getTargetDataStore() { |
| | | return targetDataStore; |
| | | } |
| | | |
| | | protected void createTargetDataStore() throws JobExecutionException |
| | | { |
| | | if (targetDataStore != null) |
| | | { |
| | | protected void createTargetDataStore() throws JobExecutionException { |
| | | if (targetDataStore != null) { |
| | | targetDataStore.dispose(); |
| | | targetDataStore = null; |
| | | } |
| | |
| | | } |
| | | */ |
| | | |
| | | if (!myProperties.containsKey("max connections" /*MySQLDataStoreFactory.MAXCONN.key */)) |
| | | { |
| | | myProperties.put("max connections", "2"); |
| | | if (!myProperties.containsKey(MySQLDataStoreFactory.MAXCONN.key)) { |
| | | myProperties.put(MySQLDataStoreFactory.MAXCONN.key, "2"); |
| | | } |
| | | |
| | | if (!myProperties.containsKey("min connections" /* MySQLDataStoreFactory.MINCONN.key */)) |
| | | { |
| | | myProperties.put("min connections", "1"); |
| | | if (!myProperties.containsKey(MySQLDataStoreFactory.MINCONN.key)) { |
| | | myProperties.put(MySQLDataStoreFactory.MINCONN.key, "1"); |
| | | } |
| | | |
| | | if (!myProperties.containsKey(MySQLDataStoreFactory.WKBENABLED.key)) |
| | | { |
| | | /* |
| | | if (!myProperties.containsKey(MySQLDataStoreFactory.WKBENABLED.key)) { |
| | | myProperties.put(MySQLDataStoreFactory.WKBENABLED.key, "true"); |
| | | } |
| | | */ |
| | | |
| | | if (!dataStoreFactory.canProcess(myProperties)) |
| | | { |
| | | if (!dataStoreFactory.canProcess(myProperties)) { |
| | | getLogger().warn("cannot process properties-"); |
| | | throw new JobExecutionException("cannot process properties-"); |
| | | } |
| | | try |
| | | { |
| | | targetDataStore = (MySQLDataStore) dataStoreFactory.createDataStore(myProperties); |
| | | } catch (IOException e) |
| | | { |
| | | try { |
| | | targetDataStore = dataStoreFactory.createDataStore(myProperties); |
| | | } catch (IOException e) { |
| | | getLogger().warn(e.getMessage(), e); |
| | | throw new JobExecutionException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | protected void disconnect() { |
| | | super.disconnect(); |
| | | if (targetDataStore != null) { |
| | | targetDataStore.dispose(); |
| | | targetDataStore = null; |
| | | } |
| | | } |
| | | } |
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2OraSDOJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleElementLogger.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleIncrementDgn2PostGISJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleTransformColorOwner2CSVJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleTransformColorOwnerJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleUpgradeBlob2UDTJob.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractDgnFileJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/AbstractOracleJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/OracleUpgradeJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/AbstractDgnToEdbGeoJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/AbstractOracleToEdbGeoJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/DummyFeatureConvertEdbGeoJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/FeatureDgnConvertEdbGeoJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/GeneralDgnConvertEdbGeoJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/IndexDgnConvertEdbGeoJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/edbgeo/OracleConvertEdbGeoJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractDgnToMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/AbstractOracleToMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/DummyFeatureConvertMySQlJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/FeatureDgnConvertMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/GeneralDgnConvertMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/IndexDgnConvertMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/mysql/OracleConvertMySQLJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractDgnToOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/AbstractOracleToOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/DummyFeatureConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/FeatureDgnConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/GeneralDgnConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/IndexDgnConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/orasdo/OracleConvertOraSDOJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertGeoServerContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleIncrementPostGISJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/AbstractDgnToShapefileJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/DummyFeatureConvertShpJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/FeatureDgnConvertShpJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/GeneralDgnConvertShpJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/IndexDgnConvertShpJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/shapefile/OracleConvertShapefilesJobContext.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/Base64.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/BinConverter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/Bits.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ByteArrayCompressor.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ConnectivityDirectionEnum.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/EPSG3825GeometryConverterDecorator.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/EPSG3826GeometryConverterDecorator.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ElementDigesterUtils.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FeatureTypeBuilderUtil.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/FileUtils.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/GeomUtil.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/GeometryConverterDecorator.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/LangUtil.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/PrintfFormat.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/StringUtils.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TPCLIDConverter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TWDDatumConverter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/XGeosConfigDigesterUtils.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JTSShape.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsBinaryParser.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsBinaryWriter.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsGeometry.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsGisWrapper.java
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/postjts/JtsWrapper.java
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/filter/ElementDispatcherRules.xml
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/filter/FeatureClassificationRules.xml
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/filter/digester-rules-3.0.dtd
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/geoserver/config/DefaultXGeosDataConfigRules.xml
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/geoserver/config/digester-rules-3.0.dtd
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/geoserver/config/xgeosdataconfig-1.xml
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/geoserver/config/xgeosdataconfig.xml
xdgnjobs/ximple-spatialjob/src/main/resources/conf/DefaultConvertShpFilter.xml
xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/filter/ElementDispatcherTest.java
xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/rest/GeoManagerEncoderTest.java
xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/util/FeatureTypeBuilderUtilTest.java
xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/util/FileUtilsTest.java |