Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
d06fc8f6
Commit
d06fc8f6
authored
Sep 24, 2014
by
bruse
Browse files
I introduced a new JobDescriptor and an adjusted JobBuilder.
parent
b1ffe7fe
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/eu/simstadt/nf/JobBuilder.java
0 → 100644
View file @
d06fc8f6
package
eu.simstadt.nf
;
/**
* Implementations of JobBuilder build nF import and export jobs using nF's XML job format. There should be
* one implementation for each version of novaFACTORY. The supported version should be returned by
* supportsNFVersion().
*
* @param <T> JobBuilder takes implementations of JobDescriptor in order to populate the XML job.
* @author Marcel Bruse
*/
public
interface
JobBuilder
<
T
extends
JobDescriptor
>
{
/**
* @return Tells the caller the supported version of novaFACTORY.
*/
public
String
supportsNFVersion
();
/**
* @return The supported version of the XML export job format.
*/
public
String
supportsExportJobVersion
();
/**
* @return The supported version of the XML import job format.
*/
public
String
supportsImportJobVersion
();
/**
* Builds a XML export job document as a string. This string representation of an export job can be written
* into a file or directly sent to a novaFACTORY server instance by the caller.
*
* @param jobDescriptor A job descriptor which describes the export job with all its attributes according to
* a valid nF export job DTD.
* @return Returns a XML export job document in a string.
*/
public
String
buildExportJob
(
T
jobDescriptor
);
/**
* Builds a XML import job document as a string. This string representation of an import job can be written
* into a file or directly sent to a nF server instance by the caller.
*
* @param jobDescriptor A job descriptor which describes the import job with all its attributes according to
* a valid nF import job DTD.
* @return Returns a XML import job document in a string.
*/
public
String
buildImportJob
(
T
jobDescriptor
);
}
src/eu/simstadt/nf/
NF
JobBuilder.java
→
src/eu/simstadt/nf/JobBuilder
Impl
.java
View file @
d06fc8f6
package
eu.simstadt.nf
;
import
java.io.StringWriter
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.DocumentBuilderFactory
;
...
...
@@ -26,174 +28,215 @@
import
org.w3c.dom.Element
;
/**
* Builds nF import and export jobs using nF's XML job format.
* Builds nF import and export jobs using nF's XML job format. Please read the nF manual if you want more
* details about the numerous job attributes listed below.
*
* @param <T> JobBuilder takes implementations of JobDescriptor in order to populate the XML job.
* @author Marcel Bruse
*/
public
class
NFJobBuilder
{
public
class
JobBuilderImpl
implements
JobBuilder
<
JobDescriptorImpl
>
{
/** Supported version of the novaFACTORY. */
public
static
final
String
NOVA_FACTORY_VERSION
=
"6.3.1.1"
;
/** The version of the XML export job format. */
public
static
final
String
EXPORT_JOB_VERSION
=
"1.0.0"
;
@Override
public
String
supportsNFVersion
()
{
return
NOVA_FACTORY_VERSION
;
}
@Override
public
String
supportsExportJobVersion
()
{
return
EXPORT_JOB_VERSION
;
}
@Override
public
String
supportsImportJobVersion
()
{
return
null
;
}
/**
* This is an intermediate prototype.
*
* @param regionPolygon A polygon of geo coordinates which encloses the buildings to be downloaded.
* @param jobDescriptor A job descriptor which describes the export job with all its attributes according to
* a valid nF export job DTD.
* @return Returns a string representation of the nF export job.
*/
public
static
String
buildExportJob
(
List
<
Coord
>
regionPolygon
)
{
@Override
public
String
buildExportJob
(
JobDescriptorImpl
jobDescriptor
)
{
String
result
=
null
;
try
{
DocumentBuilderFactory
factory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
Document
doc
=
builder
.
newDocument
();
Element
root
=
doc
.
createElement
(
"EXPORT_JOB"
);
root
.
setAttribute
(
"version"
,
"1.0.0"
);
doc
.
appendChild
(
root
);
Element
job
=
doc
.
createElement
(
"job"
);
root
.
appendChild
(
job
);
if
(
Objects
.
nonNull
(
jobDescriptor
)
&&
jobDescriptor
.
isValid
())
{
try
{
DocumentBuilderFactory
factory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
Document
doc
=
builder
.
newDocument
();
Element
root
=
doc
.
createElement
(
"EXPORT_JOB"
);
root
.
setAttribute
(
"version"
,
supportsExportJobVersion
()
);
doc
.
appendChild
(
root
);
Element
job
=
doc
.
createElement
(
"job"
);
root
.
appendChild
(
job
);
Element
initiator
=
doc
.
createElement
(
"initiator"
);
initiator
.
appendChild
(
doc
.
createTextNode
(
"2758"
));
initiator
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getInitiator
()
));
job
.
appendChild
(
initiator
);
Element
jobnumber
=
doc
.
createElement
(
"jobnumber"
);
jobnumber
.
appendChild
(
doc
.
createTextNode
(
"GR_EXPORT_CITYGML_LOD1"
));
jobnumber
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getJobnumber
()
));
job
.
appendChild
(
jobnumber
);
Element
account
=
doc
.
createElement
(
"account"
);
account
.
appendChild
(
doc
.
createTextNode
(
"Habib"
));
job
.
appendChild
(
account
);
Element
product
=
doc
.
createElement
(
"product"
);
product
.
appendChild
(
doc
.
createTextNode
(
"LBTEST"
));
root
.
appendChild
(
product
);
Element
layers
=
doc
.
createElement
(
"layers"
);
layers
.
setAttribute
(
"color"
,
"0"
);
layers
.
setAttribute
(
"mono"
,
"0"
);
layers
.
setAttribute
(
"plotLabelSrs"
,
"-1"
);
layers
.
setAttribute
(
"plotframe"
,
"0"
);
layers
.
setAttribute
(
"single"
,
"1"
);
root
.
appendChild
(
layers
);
Element
layer
=
doc
.
createElement
(
"layer"
);
layer
.
setAttribute
(
"name"
,
"GML"
);
layer
.
setAttribute
(
"product"
,
"LBTEST"
);
layer
.
setAttribute
(
"style"
,
"#000000"
);
layers
.
appendChild
(
layer
);
Element
srs
=
doc
.
createElement
(
"srs"
);
srs
.
appendChild
(
doc
.
createTextNode
(
"31467"
));
root
.
appendChild
(
srs
);
Element
extent
=
doc
.
createElement
(
"extent"
);
extent
.
setAttribute
(
"merge_mapsheets"
,
"off"
);
extent
.
setAttribute
(
"tile1asgn"
,
"false"
);
root
.
appendChild
(
extent
);
Element
polygon
=
appendRegionPolygon
(
doc
,
regionPolygon
);
Element
product
=
doc
.
createElement
(
"product"
);
product
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getProduct
()));
root
.
appendChild
(
product
);
Element
layers
=
doc
.
createElement
(
"layers"
);
layers
.
setAttribute
(
"color"
,
jobDescriptor
.
getColor
());
layers
.
setAttribute
(
"mono"
,
jobDescriptor
.
getMono
());
layers
.
setAttribute
(
"plotLabelSrs"
,
jobDescriptor
.
getPlotLabelSrs
());
layers
.
setAttribute
(
"plotframe"
,
jobDescriptor
.
getPlotframe
());
layers
.
setAttribute
(
"single"
,
jobDescriptor
.
getSingle
());
root
.
appendChild
(
layers
);
appendLayers
(
doc
,
layers
,
jobDescriptor
.
getLayerList
());
Element
srs
=
doc
.
createElement
(
"srs"
);
srs
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getSrs
()));
root
.
appendChild
(
srs
);
Element
extent
=
doc
.
createElement
(
"extent"
);
extent
.
setAttribute
(
"merge_mapsheets"
,
jobDescriptor
.
getMergeMapsheets
());
root
.
appendChild
(
extent
);
Element
polygon
=
appendRegionPolygon
(
doc
,
jobDescriptor
.
regionPolygon
);
extent
.
appendChild
(
polygon
);
Element
resolution
=
doc
.
createElement
(
"resolution"
);
resolution
.
appendChild
(
doc
.
createTextNode
(
"100.0"
));
root
.
appendChild
(
resolution
);
Element
scale
=
doc
.
createElement
(
"scale"
);
scale
.
appendChild
(
doc
.
createTextNode
(
"10000.0"
));
root
.
appendChild
(
scale
);
Element
format
=
doc
.
createElement
(
"format"
);
format
.
setAttribute
(
"alphalinscale"
,
"0.0"
);
format
.
setAttribute
(
"alphascale"
,
"1.0"
);
format
.
setAttribute
(
"citygml_actfunc"
,
"tolod1"
);
format
.
setAttribute
(
"citygml_apptheme"
,
""
);
format
.
setAttribute
(
"citygml_elemclasses"
,
"true"
);
format
.
setAttribute
(
"citygml_lodmode"
,
"all"
);
format
.
setAttribute
(
"citygml_lods"
,
"1"
);
format
.
setAttribute
(
"citygml_metadata"
,
"true"
);
format
.
setAttribute
(
"citygml_outmode"
,
"normal"
);
format
.
setAttribute
(
"dtm"
,
"false"
);
format
.
setAttribute
(
"foredit"
,
"false"
);
format
.
setAttribute
(
"materialcopymode"
,
"none"
);
format
.
setAttribute
(
"polyopts_reverse"
,
"false"
);
format
.
setAttribute
(
"relcoords"
,
"false"
);
format
.
setAttribute
(
"rooftxr"
,
"false"
);
format
.
setAttribute
(
"roundcoords"
,
"3"
);
format
.
setAttribute
(
"schemetxr"
,
"false"
);
format
.
setAttribute
(
"solar"
,
"false"
);
format
.
setAttribute
(
"solargeoplex"
,
"false"
);
format
.
setAttribute
(
"tex"
,
"false"
);
format
.
setAttribute
(
"tolod1"
,
"true"
);
format
.
setAttribute
(
"tolod1_add"
,
"false"
);
format
.
setAttribute
(
"tolod1_delrest"
,
"false"
);
format
.
setAttribute
(
"tolod1_dstattrabsgrnd"
,
""
);
format
.
setAttribute
(
"tolod1_dstattrabsheight"
,
""
);
format
.
setAttribute
(
"tolod1_dstattrrelheight"
,
""
);
format
.
setAttribute
(
"tolod1_dstattrzmode"
,
""
);
format
.
setAttribute
(
"tolod1_geommode"
,
"lod1solid"
);
format
.
setAttribute
(
"tolod1_lodsrcmode"
,
"all"
);
format
.
setAttribute
(
"tolod1_triangulate"
,
"false"
);
format
.
setAttribute
(
"tolod1_zroofmode"
,
"mid"
);
format
.
setAttribute
(
"tolod1_zusegenattrs"
,
""
);
format
.
setAttribute
(
"tolod1_zusemeasuredheight"
,
"false"
);
format
.
setAttribute
(
"xyz"
,
"false"
);
format
.
appendChild
(
doc
.
createTextNode
(
"CityGML"
));
root
.
appendChild
(
format
);
Element
exportmetadata
=
doc
.
createElement
(
"exportmetadata"
);
exportmetadata
.
setAttribute
(
"calibration"
,
"0"
);
exportmetadata
.
setAttribute
(
"xmetadata"
,
"0"
);
exportmetadata
.
appendChild
(
doc
.
createTextNode
(
"1"
));
root
.
appendChild
(
exportmetadata
);
Element
addfile
=
doc
.
createElement
(
"addfile"
);
addfile
.
setAttribute
(
"col"
,
"0"
);
addfile
.
setAttribute
(
"eck"
,
""
);
root
.
appendChild
(
addfile
);
Element
usenodatamask
=
doc
.
createElement
(
"usenodatamask"
);
usenodatamask
.
appendChild
(
doc
.
createTextNode
(
"0"
));
root
.
appendChild
(
usenodatamask
);
Element
usepdctborderpoly
=
doc
.
createElement
(
"usepdctborderpoly"
);
usepdctborderpoly
.
appendChild
(
doc
.
createTextNode
(
"0"
));
root
.
appendChild
(
usepdctborderpoly
);
Element
dhkresolvereferences
=
doc
.
createElement
(
"dhkresolvereferences"
);
dhkresolvereferences
.
appendChild
(
doc
.
createTextNode
(
"1"
));
root
.
appendChild
(
dhkresolvereferences
);
Element
zipresult
=
doc
.
createElement
(
"zipresult"
);
zipresult
.
appendChild
(
doc
.
createTextNode
(
"0"
));
root
.
appendChild
(
zipresult
);
Element
userdescription
=
doc
.
createElement
(
"userdescription"
);
root
.
appendChild
(
userdescription
);
Element
namingpattern
=
doc
.
createElement
(
"namingpattern"
);
root
.
appendChild
(
namingpattern
);
TransformerFactory
transformerFactory
=
TransformerFactory
.
newInstance
();
Transformer
transformer
=
transformerFactory
.
newTransformer
();
StringWriter
writer
=
new
StringWriter
();
StreamResult
streamResult
=
new
StreamResult
(
writer
);
transformer
.
transform
(
new
DOMSource
(
doc
),
streamResult
);
result
=
writer
.
toString
();
}
catch
(
ParserConfigurationException
ex
)
{
// TODO Auto-generated catch block
ex
.
printStackTrace
();
}
catch
(
TransformerConfigurationException
ex
)
{
// TODO Auto-generated catch block
ex
.
printStackTrace
();
}
catch
(
TransformerException
ex
)
{
// TODO Auto-generated catch block
ex
.
printStackTrace
();
Element
resolution
=
doc
.
createElement
(
"resolution"
);
resolution
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getResolution
()));
root
.
appendChild
(
resolution
);
Element
scale
=
doc
.
createElement
(
"scale"
);
scale
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getScale
()));
root
.
appendChild
(
scale
);
Element
format
=
doc
.
createElement
(
"format"
);
// TODO
format
.
setAttribute
(
"alphalinscale"
,
"0.0"
);
format
.
setAttribute
(
"alphascale"
,
"1.0"
);
format
.
setAttribute
(
"citygml_actfunc"
,
"tolod1"
);
format
.
setAttribute
(
"citygml_apptheme"
,
""
);
format
.
setAttribute
(
"citygml_elemclasses"
,
"true"
);
format
.
setAttribute
(
"citygml_lodmode"
,
"all"
);
format
.
setAttribute
(
"citygml_lods"
,
"1"
);
format
.
setAttribute
(
"citygml_metadata"
,
"true"
);
format
.
setAttribute
(
"citygml_outmode"
,
"normal"
);
format
.
setAttribute
(
"dtm"
,
"false"
);
format
.
setAttribute
(
"foredit"
,
"false"
);
format
.
setAttribute
(
"materialcopymode"
,
"none"
);
format
.
setAttribute
(
"polyopts_reverse"
,
"false"
);
format
.
setAttribute
(
"relcoords"
,
"false"
);
format
.
setAttribute
(
"rooftxr"
,
"false"
);
format
.
setAttribute
(
"roundcoords"
,
"3"
);
format
.
setAttribute
(
"schemetxr"
,
"false"
);
format
.
setAttribute
(
"solar"
,
"false"
);
format
.
setAttribute
(
"solargeoplex"
,
"false"
);
format
.
setAttribute
(
"tex"
,
"false"
);
format
.
setAttribute
(
"tolod1"
,
"true"
);
format
.
setAttribute
(
"tolod1_add"
,
"false"
);
format
.
setAttribute
(
"tolod1_delrest"
,
"false"
);
format
.
setAttribute
(
"tolod1_dstattrabsgrnd"
,
""
);
format
.
setAttribute
(
"tolod1_dstattrabsheight"
,
""
);
format
.
setAttribute
(
"tolod1_dstattrrelheight"
,
""
);
format
.
setAttribute
(
"tolod1_dstattrzmode"
,
""
);
format
.
setAttribute
(
"tolod1_geommode"
,
"lod1solid"
);
format
.
setAttribute
(
"tolod1_lodsrcmode"
,
"all"
);
format
.
setAttribute
(
"tolod1_triangulate"
,
"false"
);
format
.
setAttribute
(
"tolod1_zroofmode"
,
"mid"
);
format
.
setAttribute
(
"tolod1_zusegenattrs"
,
""
);
format
.
setAttribute
(
"tolod1_zusemeasuredheight"
,
"false"
);
format
.
setAttribute
(
"xyz"
,
"false"
);
format
.
appendChild
(
doc
.
createTextNode
(
"CityGML"
));
root
.
appendChild
(
format
);
Element
exportmetadata
=
doc
.
createElement
(
"exportmetadata"
);
exportmetadata
.
setAttribute
(
"calibration"
,
jobDescriptor
.
getCalibration
());
exportmetadata
.
setAttribute
(
"xmetadata"
,
jobDescriptor
.
getXmetadata
());
exportmetadata
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getExportmetadata
()));
root
.
appendChild
(
exportmetadata
);
Element
addfile
=
doc
.
createElement
(
"addfile"
);
addfile
.
setAttribute
(
"col"
,
jobDescriptor
.
getCol
());
addfile
.
setAttribute
(
"eck"
,
jobDescriptor
.
getEck
());
root
.
appendChild
(
addfile
);
Element
usenodatamask
=
doc
.
createElement
(
"usenodatamask"
);
usenodatamask
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getUsenodatamask
()));
root
.
appendChild
(
usenodatamask
);
Element
usepdctborderpoly
=
doc
.
createElement
(
"usepdctborderpoly"
);
usepdctborderpoly
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getUsepdctborderpoly
()));
root
.
appendChild
(
usepdctborderpoly
);
Element
dhkresolvereferences
=
doc
.
createElement
(
"dhkresolvereferences"
);
dhkresolvereferences
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getDhkresolvereferences
()));
root
.
appendChild
(
dhkresolvereferences
);
Element
zipresult
=
doc
.
createElement
(
"zipresult"
);
zipresult
.
appendChild
(
doc
.
createTextNode
(
jobDescriptor
.
getZipresult
()));
root
.
appendChild
(
zipresult
);
Element
userdescription
=
doc
.
createElement
(
"userdescription"
);
root
.
appendChild
(
userdescription
);
Element
namingpattern
=
doc
.
createElement
(
"namingpattern"
);
root
.
appendChild
(
namingpattern
);
TransformerFactory
transformerFactory
=
TransformerFactory
.
newInstance
();
Transformer
transformer
=
transformerFactory
.
newTransformer
();
StringWriter
writer
=
new
StringWriter
();
StreamResult
streamResult
=
new
StreamResult
(
writer
);
transformer
.
transform
(
new
DOMSource
(
doc
),
streamResult
);
result
=
writer
.
toString
();
}
catch
(
ParserConfigurationException
ex
)
{
// TODO Auto-generated catch block
ex
.
printStackTrace
();
}
catch
(
TransformerConfigurationException
ex
)
{
// TODO Auto-generated catch block
ex
.
printStackTrace
();
}
catch
(
TransformerException
ex
)
{
// TODO Auto-generated catch block
ex
.
printStackTrace
();
}
}
return
result
;
}
private
void
appendLayers
(
Document
doc
,
Element
layers
,
ArrayList
<
Layer
>
layerList
)
{
for
(
Layer
layer
:
layerList
)
{
Element
layerElement
=
doc
.
createElement
(
"layer"
);
layerElement
.
setAttribute
(
"name"
,
layer
.
getName
());
String
product
=
layer
.
getProduct
();
if
(
Objects
.
nonNull
(
product
)
&&
!
product
.
isEmpty
())
{
layerElement
.
setAttribute
(
"product"
,
product
);
}
String
style
=
layer
.
getStyle
();
if
(
Objects
.
nonNull
(
style
)
&&
!
style
.
isEmpty
())
{
layerElement
.
setAttribute
(
"style"
,
style
);
}
layers
.
appendChild
(
layerElement
);
}
}
/**
* Transforms a global WGS 84 position into a coordinate of the given target SRS.
*
...
...
@@ -253,4 +296,10 @@ private static Element appendRegionPolygon(Document doc, List<Coord> regionPolyg
return
polygon
;
}
@Override
public
String
buildImportJob
(
JobDescriptorImpl
jobDescriptor
)
{
// TODO Auto-generated method stub
return
null
;
}
}
src/eu/simstadt/nf/JobDescriptor.java
0 → 100644
View file @
d06fc8f6
package
eu.simstadt.nf
;
/**
* Every instance of this class describes an export or import job for the novaFACTORY. Instances of JobBuilder
* take JobDescriptions and build XML export and import job files out of it.
*
* @author Marcel Bruse
*/
public
interface
JobDescriptor
{
/**
* @return The supported version of the XML export job format.
*/
public
String
supportsExportJobVersion
();
/**
* @return The supported version of the XML import job format.
*/
public
String
supportsImportJobVersion
();
}
src/eu/simstadt/nf/JobDescriptorImpl.java
0 → 100644
View file @
d06fc8f6
package
eu.simstadt.nf
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Every instance of this class describes an export or import job for the novaFACTORY. Instances of JobBuilder
* take JobDescriptions and build XML export and import job files out of it.
*
* @author Marcel Bruse
*/
public
class
JobDescriptorImpl
implements
JobDescriptor
{
private
static
final
String
DEFAULT_ACCOUNT
=
"Habib"
;
private
static
final
String
DEFAULT_XMETA_DATA
=
"0"
;
private
static
final
String
DEFAULT_CALIBRATION
=
"0"
;
private
static
final
String
DEFAULT_PRODUCT
=
"LBTEST"
;
private
static
final
String
DEFAULT_ZIP_RESULT
=
"0"
;
private
static
final
String
DEFAULT_DHK_RESOLVE_REFERENCES
=
"1"
;
private
static
final
String
DEFAULT_USE_PDCT_BORDER_POLY
=
"0"
;
private
static
final
String
DEFAULT_USE_NO_DATA_MASK
=
"0"
;
private
static
final
String
DEFAULT_ECK
=
"0"
;
private
static
final
String
DEFAULT_COL
=
"0"
;
private
static
final
String
DEFAULT_EXPORT_META_DATA
=
"1"
;
private
static
final
String
DEFAULT_FORMAT
=
"CityGML"
;
private
static
final
String
DEFAULT_SCALE
=
"10000.0"
;
private
static
final
String
DEFAULT_RESOLUTION
=
"100.0"
;
private
static
final
String
DEFAULT_MERGE_MAP_SHEETS
=
"off"
;
private
static
final
String
DEFAULT_SRS
=
"31467"
;
private
static
final
String
DEFAULT_SINGLE
=
"1"
;
private
static
final
String
DEFAULT_PLOTFRAME
=
"0"
;
private
static
final
String
DEFAULT_PLOT_LABEL_SRS
=
"-1"
;
private
static
final
String
DEFAULT_MONO
=
"0"
;
private
static
final
String
DEFAULT_COLOR
=
"0"
;
private
static
final
String
DEFAULT_JOBNUMBER
=
"GR_EXPORT_CITYGML_LOD1"
;
private
static
final
String
DEFAULT_INITIATOR
=
"2758"
;
/** The version of the novaFACTORY XML export job format. */
public
static
final
String
EXPORT_JOB_VERSION
=
"1.0.0"
;
/** TODO: Who or what is this initiator? */
private
String
initiator
;
/** The number of the job which can actually be a string. */
private
String
jobnumber
;
/** The account or user for which a job should be executed. */
private
String
account
;
/** The product for which a job should be executed. */
private
String
product
;
/** Color attribute of the layers tag. */
private
String
color
;
/** The mono attribute of the layers tag. */
private
String
mono
;
/** The plotLabelSrs flag of the layers tag. */
private
String
plotLabelSrs
;
/** The plotframe flag of the layers tag. */
private
String
plotframe
;
/** The single flag of the layers tag. */
private
String
single
;
/** The layers which will be involved in a job. */
private
ArrayList
<
Layer
>
layerList
=
new
ArrayList
<>();
/** The SRS for the job. */
private
String
srs
;
/** The merge_mapsheets attribute of the extend tag. */
private
String
mergeMapsheets
;
/** The polygon of the selected region which should be exported. */
ArrayList
<
Coord
>
regionPolygon
=
new
ArrayList
<>();
/** The resolution for the job. */
private
String
resolution
;
/** The scale for the job. */
private
String
scale
;
/** The format for the job. E.g. CityGML. */
private
String
format
;
/** The exportmetadata flag for the job. */
private
String
exportmetadata
;
/** The col attribute of the addfile tag. */
private
String
col
;
/** The eck attribute of the addfile tag. */
private
String
eck
;
/** The usenodatamask flag for the job. */
private
String
usenodatamask
;
/** The usepdctborderpoly flag for the job. */
private
String
usepdctborderpoly
;
/** The dhkresolvereferences flag for the job. */
private
String
dhkresolvereferences
;
/** Flag for zipped results. */
private
String
zipresult
;
/** The calibration attribute of the exportmetadata tag. */
private
String
calibration
;
/** The xmetadata attribute of the exportmetadata tag. */
private
String
xmetadata
;
public
String
getInitiator
()
{
return
initiator
;
}
public
void
setInitiator
(
String
initiator
)
{
this
.
initiator
=
initiator
;
}
public
String
getJobnumber
()
{
return
jobnumber
;
}
public
void
setJobnumber
(
String
jobnumber
)
{
this
.
jobnumber
=
jobnumber
;
}
public
String
getAccount
()
{
return
account
;
}
public
void
setAccount
(
String
account
)
{
this
.
account
=
account
;
}
public
String
getProduct
()
{
return
product
;
}
public
void
setProduct
(
String
product
)
{
this
.
product
=
product
;
}
public
String
getColor
()
{
return
color
;
}
public
void
setColor
(
String
color
)
{
this
.
color
=
color
;
}
public
String
getMono
()
{
return
mono
;
}
public
void
setMono
(
String
mono
)
{
this
.
mono
=
mono
;
}
public
String
getPlotLabelSrs
()
{
return
plotLabelSrs
;
}
public
void
setPlotLabelSrs
(
String
plotLabelSrs
)
{
this
.
plotLabelSrs
=
plotLabelSrs
;
}
public
String
getPlotframe
()
{
return
plotframe
;
}
public
void
setPlotframe
(
String
plotframe
)
{
this
.
plotframe
=
plotframe
;
}
public
String
getSingle
()
{
return
single
;
}
public
void
setSingle
(
String
single
)
{
this
.
single
=
single
;
}
public
ArrayList
<
Layer
>
getLayerList
()
{
return
layerList
;
}
public
void
setLayerList
(
ArrayList
<
Layer
>
layerList
)
{
this
.
layerList
=
layerList
;
}
public
void
addLayer
(
Layer
layer
)
{
layerList
.
add
(
layer
);
}
public
String
getSrs
()
{
return
srs
;
}
public
void
setSrs
(
String
srs
)
{
this
.
srs
=
srs
;
}
public
String
getMergeMapsheets
()
{
return
mergeMapsheets
;
}
public
void
setMergeMapsheets
(
String
mergeMapsheets
)
{
this
.
mergeMapsheets
=
mergeMapsheets
;
}
public
String
getResolution
()
{
return
resolution
;
}
public
void
setResolution
(
String
resolution
)
{
this
.
resolution
=
resolution
;
}
public
String
getScale
()
{
return
scale
;
}
public
void
setScale
(
String
scale
)
{
this
.
scale
=
scale
;
}
public
String
getFormat
()
{
return
format
;
}
public
void
setFormat
(
String
format
)
{
this
.
format
=
format
;
}
public
String
getExportmetadata
()
{
return
exportmetadata
;
}
public
void
setExportmetadata
(
String
exportmetadata
)
{
this
.
exportmetadata
=
exportmetadata
;
}
public
String
getCol
()
{
return
col
;
}
public
void
setCol
(
String
col
)
{
this
.
col
=
col
;
}
public
String
getEck
()
{
return
eck
;
}
public
void
setEck
(
String
eck
)
{
this
.
eck
=
eck
;
}
public
String
getUsenodatamask
()
{
return
usenodatamask
;
}
public
void
setUsenodatamask
(
String
usenodatamask
)
{
this
.
usenodatamask
=
usenodatamask
;
}
public
String
getUsepdctborderpoly
()
{
return
usepdctborderpoly
;
}
public
void
setUsepdctborderpoly
(
String
usepdctborderpoly
)
{
this
.
usepdctborderpoly
=
usepdctborderpoly
;
}
public
String
getDhkresolvereferences
()
{
return
dhkresolvereferences
;
}
public
void
setDhkresolvereferences
(
String
dhkresolvereferences
)
{
this
.
dhkresolvereferences
=
dhkresolvereferences
;
}
public
String
getZipresult
()
{
return
zipresult
;
}
public
void
setZipresult
(
String
zipresult
)
{
this
.
zipresult
=
zipresult
;
}
public
String
getCalibration
()
{
return
calibration
;
}
public
void
setCalibration
(
String
calibration
)
{
this
.
calibration
=
calibration
;
}
public
String
getXmetadata
()
{
return
xmetadata
;
}
public
void
setXmetadata
(
String
xmetadata
)
{
this
.
xmetadata
=
xmetadata
;
}
@Override
public
String
supportsExportJobVersion
()
{
return
EXPORT_JOB_VERSION
;
}
@Override
public
String
supportsImportJobVersion
()
{
// TODO Auto-generated method stub
return
null
;
}
/**
* Adds a new coordinate to the region polygon. A region polygon is only used for export jobs.
*
* @param coordinate The new coordiante of the region polygon of a export job.
*/
public
void
addCoordinateToRegionPolygon
(
Coord
coordinate
)
{
regionPolygon
.
add
(
coordinate
);
}
/**
* Sets the whole region polygon for an export job.
*
* @param regionPolygon The region polygon to be used for an export job.
*/
public
void
setRegionPolygon
(
List
<
Coord
>
regionPolygon
)
{
this
.
regionPolygon
.
clear
();
this
.
regionPolygon
.
addAll
(
regionPolygon
);
}
/**
* @return Returns the region polygon.
*/
public
ArrayList
<
Coord
>
getRegionPolygon
()
{
return
regionPolygon
;
}
/**
* @return Returns true, if all mandatory elements and attributes are set. Otherwise, false.
*/
public
boolean
isValid
()
{
if
(
regionPolygon
.
isEmpty
()
||
layerList
.
isEmpty
()
||
initiator
.
isEmpty
()
||
account
.
isEmpty
()
||
jobnumber
.
isEmpty
()
||
product
.
isEmpty
()
||
color
.
isEmpty
()
||
mono
.
isEmpty
()
||
plotLabelSrs
.
isEmpty
()
||
plotframe
.
isEmpty
()
||
single
.
isEmpty
()
||
srs
.
isEmpty
()
||
resolution
.
isEmpty
()
||
scale
.
isEmpty
()
||
format
.
isEmpty
()
||
exportmetadata
.
isEmpty
()
||
col
.
isEmpty
()
||
eck
.
isEmpty
()){
return
false
;
}
else
{
return
true
;
}
}
public
static
JobDescriptorImpl
getDefaultDescriptor
()
{
JobDescriptorImpl
descriptor
=
new
JobDescriptorImpl
();
descriptor
.
setInitiator
(
DEFAULT_INITIATOR
);
descriptor
.
setJobnumber
(
DEFAULT_JOBNUMBER
);
descriptor
.
setAccount
(
DEFAULT_ACCOUNT
);
descriptor
.
setProduct
(
DEFAULT_PRODUCT
);
descriptor
.
setColor
(
DEFAULT_COLOR
);
descriptor
.
setMono
(
DEFAULT_MONO
);
descriptor
.
setPlotLabelSrs
(
DEFAULT_PLOT_LABEL_SRS
);
descriptor
.
setPlotframe
(
DEFAULT_PLOTFRAME
);
descriptor
.
setSingle
(
DEFAULT_SINGLE
);
descriptor
.
setSrs
(
DEFAULT_SRS
);
descriptor
.
setMergeMapsheets
(
DEFAULT_MERGE_MAP_SHEETS
);
descriptor
.
setResolution
(
DEFAULT_RESOLUTION
);
descriptor
.
setScale
(
DEFAULT_SCALE
);
descriptor
.
setFormat
(
DEFAULT_FORMAT
);
descriptor
.
setExportmetadata
(
DEFAULT_EXPORT_META_DATA
);
descriptor
.
setCol
(
DEFAULT_COL
);
descriptor
.
setEck
(
DEFAULT_ECK
);
descriptor
.
setUsenodatamask
(
DEFAULT_USE_NO_DATA_MASK
);
descriptor
.
setUsepdctborderpoly
(
DEFAULT_USE_PDCT_BORDER_POLY
);
descriptor
.
setDhkresolvereferences
(
DEFAULT_DHK_RESOLVE_REFERENCES
);
descriptor
.
setZipresult
(
DEFAULT_ZIP_RESULT
);
descriptor
.
setCalibration
(
DEFAULT_CALIBRATION
);
descriptor
.
setXmetadata
(
DEFAULT_XMETA_DATA
);
return
descriptor
;
}
}
src/eu/simstadt/nf/Layer.java
0 → 100644
View file @
d06fc8f6
package
eu.simstadt.nf
;
/**
* A layer describes an aspect of a nF product and the type of its data. For instance, a layer could contain
* all house numbers of all buildings of the product.
*
* @author Marcel Bruse
*
*/
public
class
Layer
{
/** The name of the layer. */
private
String
name
;
/** The name of the product to which this layer belongs. */
private
String
product
;
/** The style of this layer. Should be a color code (?). */
private
String
style
;
/**
* @return Returns the name of the layer.
*/
public
String
getName
()
{
return
name
;
}
/**
* Sets the name of the layer.
*
* @param name The name of the layer.
*/
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
/**
* @return Returns the name of the layer's product.
*/
public
String
getProduct
()
{
return
product
;
}
/**
* Sets the product of this layer.
*
* @param product The product of this layer.
*/
public
void
setProduct
(
String
product
)
{
this
.
product
=
product
;
}
/**
* @return Returns the style of the layer.
*/
public
String
getStyle
()
{
return
style
;
}
/**
* Sets the style of this layer. Should be a color code (?).
*
* @param style The style of this layer.
*/
public
void
setStyle
(
String
style
)
{
this
.
style
=
style
;
}
}
src/eu/simstadt/nf/Main.java
View file @
d06fc8f6
package
eu.simstadt.nf
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.PrintWriter
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
// List<Coord> regionPolygon = Arrays.asList(
// new Coord(48.879696, 9.215463),
// new Coord(48.878230, 9.215714),
// new Coord(48.878323, 9.216613),
// new Coord(48.879402, 9.216532)
// );
// String exportJobDescription = NFJobBuilder.buildExportJob(regionPolygon);
//
// String filename = "tmp.xml";
//
// try {
// PrintWriter writer = new PrintWriter(filename);
// writer.print(exportJobDescription);
// writer.close();
//
// File exportJobFile = new File(filename);
// NFConnector connector = new NFConnectorImpl("193.196.136.164");
// JobStatus status = connector.sendExportJob(exportJobFile);
// System.out.println(status + " - " + status.getMessage());
// } catch (FileNotFoundException ex) {
// // TODO Auto-generated catch block
// ex.printStackTrace();
// }
NFConnector
connector
=
new
NFConnectorImpl
(
"193.196.136.164"
);
JobStatus
status
=
connector
.
requestJobStatus
(
445
);
System
.
out
.
println
(
status
+
" - "
+
status
.
getMessage
());
if
(
status
.
isFinished
())
{
File
file
=
connector
.
requestJobResult
(
445
);
System
.
out
.
println
(
file
.
canRead
());
}
}
}
\ No newline at end of file
src/eu/simstadt/nf/NFConnectorImpl.java
View file @
d06fc8f6
...
...
@@ -330,9 +330,9 @@ public JobStatus sendExportJob(File file) {
try
{
URL
url
=
buildURL
(
REMOTE_ORDER_SERVLET
,
null
);
JobStatus
status
=
sendFile
(
url
,
file
);
if
(
Objects
.
nonNull
(
status
.
getJobId
()))
{
if
(
Objects
.
nonNull
(
status
.
getJobId
())
&&
status
.
getJobId
()
>
0
)
{
status
=
requestJobStatus
(
status
.
getJobId
());
}
else
{
}
else
if
(
Objects
.
nonNull
(
status
.
getMessage
())
&&
status
.
getMessage
().
isEmpty
())
{
status
.
setMessage
(
UNKNOWN_ERROR_OCCURRED
);
}
result
=
status
;
...
...
src/eu/simstadt/regionchooser/RegionChooserController.java
View file @
d06fc8f6
...
...
@@ -23,7 +23,10 @@
import
com.lynden.gmapsfx.javascript.object.MarkerOptions
;
import
eu.simstadt.nf.Coord
;
import
eu.simstadt.nf.NFJobBuilder
;
import
eu.simstadt.nf.JobBuilderImpl
;
import
eu.simstadt.nf.JobDescriptor
;
import
eu.simstadt.nf.JobDescriptorImpl
;
import
eu.simstadt.nf.Layer
;
public
class
RegionChooserController
implements
MapComponentInitializedListener
...
...
@@ -95,9 +98,9 @@ public void mapInitialized() {
bochumInfoWindow
.
open
(
map
,
bochumMarker
);
regionPolygon
.
add
(
new
Coord
(
bochumLoc
.
getLatitude
(),
bochumLoc
.
getLongitude
()));
regionPolygon
.
add
(
new
Coord
(
hamburgLoc
.
getLatitude
(),
bochum
Loc
.
getLongitude
()));
regionPolygon
.
add
(
new
Coord
(
stuttgartLoc
.
getLatitude
(),
bochum
Loc
.
getLongitude
()));
regionPolygon
.
add
(
new
Coord
(
dresdenLoc
.
getLatitude
(),
bochum
Loc
.
getLongitude
()));
regionPolygon
.
add
(
new
Coord
(
hamburgLoc
.
getLatitude
(),
hamburg
Loc
.
getLongitude
()));
regionPolygon
.
add
(
new
Coord
(
stuttgartLoc
.
getLatitude
(),
stuttgart
Loc
.
getLongitude
()));
regionPolygon
.
add
(
new
Coord
(
dresdenLoc
.
getLatitude
(),
dresden
Loc
.
getLongitude
()));
}
// Build the nF export job description from a region polygon
...
...
@@ -109,7 +112,15 @@ protected Task<String> createTask() {
return
new
Task
<
String
>()
{
@Override
protected
String
call
()
throws
Exception
{
return
NFJobBuilder
.
buildExportJob
(
regionPolygon
);
Layer
layer
=
new
Layer
();
layer
.
setName
(
"GML"
);
layer
.
setProduct
(
"LBTEST"
);
layer
.
setStyle
(
"#000000"
);
JobDescriptorImpl
jobDescriptor
=
JobDescriptorImpl
.
getDefaultDescriptor
();
jobDescriptor
.
addLayer
(
layer
);
jobDescriptor
.
setRegionPolygon
(
regionPolygon
);
JobBuilderImpl
jobBuilder
=
new
JobBuilderImpl
();
return
jobBuilder
.
buildExportJob
(
jobDescriptor
);
}
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment