Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CityJSON export #166

Merged
merged 43 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e47863f
reorganized CityGML options in import config
clausnagel Jan 19, 2021
284d227
renamed gml:id and gml:name query filters in config
clausnagel Jan 19, 2021
13d40f2
renamed --gml-id option in CLI
clausnagel Jan 19, 2021
db339d5
reordered CityGML import options in GUI
clausnagel Jan 19, 2021
111aae3
renamed UIDCache in config
clausnagel Jan 19, 2021
a810c45
minor change to id chache classes
clausnagel Jan 20, 2021
b1abbd2
minor change
clausnagel Jan 20, 2021
40f50de
added CityJSON import option to map unknwon extensions to generic obj…
clausnagel Jan 20, 2021
9ff2124
minor change
clausnagel Jan 20, 2021
17938c7
Merge branch 'master' into cityjson-support
clausnagel Jan 20, 2021
73ea985
added first version of CityJSON writer
clausnagel Jan 20, 2021
b445b07
do not adapt feature filter when changing the CityGML export version
clausnagel Jan 20, 2021
f63ca15
avoid NPE in CityJSON writer
clausnagel Jan 21, 2021
1bb02c4
undo b445b0717da795a331c381d36616510a269fd527
clausnagel Jan 21, 2021
f91709a
moved XSLT setting to CityGML export options in config
clausnagel Jan 21, 2021
3fd37eb
minor change
clausnagel Jan 21, 2021
e51e14f
minor change
clausnagel Jan 21, 2021
e98ab65
Merge branch 'master' into cityjson-support
clausnagel Jan 21, 2021
69bab2e
Merge branch 'master' into cityjson-support
clausnagel Jan 21, 2021
e648e53
minor change
clausnagel Jan 21, 2021
93d08de
moved XLink export settings to CityGML-specific options in the config
clausnagel Jan 22, 2021
fd44ab7
added CityGML options to preferences tab in GUI
clausnagel Jan 22, 2021
e94ef49
added CityJSON export options to GUI
clausnagel Jan 22, 2021
6ba76d6
minor change
clausnagel Jan 25, 2021
258211c
added config option to define CityGML or CityJSON encoding for compre…
clausnagel Jan 25, 2021
9ce614c
added output format selection for compressed exports to preferences i…
clausnagel Jan 25, 2021
42f1e37
Merge branch 'master' into cityjson-support
clausnagel Jan 25, 2021
0023333
minor change
clausnagel Jan 25, 2021
be34634
moved envelope options from CityGML to general export preferences
clausnagel Jan 25, 2021
59ff76d
added bounding box export options to preferences in GUI
clausnagel Jan 25, 2021
2602659
CityJSON exports now respect the general bounding box export settings
clausnagel Jan 26, 2021
252a4f9
Merge branch 'master' into cityjson-support
clausnagel Jan 26, 2021
676b5c1
Merge branch 'master' into cityjson-support
clausnagel Jan 26, 2021
f3090f5
added warning dialog for CityJSON exports without tiling
clausnagel Jan 26, 2021
f24b79f
minor change
clausnagel Jan 26, 2021
54cbbe6
moved file encoding to general export options
clausnagel Jan 26, 2021
dc21e1b
added warning to export controller if CityJSON is exported without ti…
clausnagel Jan 26, 2021
1251373
minor change
clausnagel Jan 27, 2021
2c4998e
using citygml4j chunk-parser for CityJSON
clausnagel Jan 28, 2021
109569e
added option to specify the encoding of import files to config and CLI
clausnagel Jan 29, 2021
a939aeb
added pretty print option for CityGML
clausnagel Feb 1, 2021
896d733
added CityGML version hint for CityJSON exports
clausnagel Feb 1, 2021
4ff5862
renamed KML/COLLADA/glTF Export tab and preference to VIS Export
clausnagel Feb 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public Integer call() throws Exception {
}

private void setExportOptions(ExportConfig exportConfig) {
exportConfig.getCityGMLOptions().setFileEncoding(encoding);
exportConfig.getGeneralOptions().setFileEncoding(encoding);
clausnagel marked this conversation as resolved.
Show resolved Hide resolved

if (queryOption != null) {
exportConfig.getAppearances().setExportAppearances(queryOption.isExportAppearances());
Expand Down
6 changes: 6 additions & 0 deletions impexp-client/src/main/java/org/citydb/cli/ImportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class ImportCommand extends CliCommand {
description = "Files or directories to import (glob patterns allowed).")
private String[] files;

@CommandLine.Option(names = "--input-encoding",
description = "Encoding of the input file(s).")
private String encoding;

@CommandLine.Option(names = "--import-log", paramLabel = "<file>",
description = "Record imported top-level features to this file.")
private Path importLogFile;
Expand Down Expand Up @@ -97,6 +101,8 @@ public Integer call() throws Exception {
}

private void setImportOptions(ImportConfig importConfig) {
importConfig.getGeneralOptions().setFileEncoding(encoding);

if (importLogFile != null) {
importConfig.getImportLog().setLogFile(importLogFile.toAbsolutePath().toString());
importConfig.getImportLog().setLogImportedFeatures(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.nio.file.Path;

public class DeleteListOption implements CliOption {
enum Type {gml, db}
enum Type {resource, db}

@CommandLine.Option(names = {"-f", "--delete-list"}, required = true,
description = "Name of the CSV file containing the delete list.")
Expand All @@ -55,7 +55,7 @@ enum Type {gml, db}
description = "Index of the id column (default: 1).")
private Integer index;

@CommandLine.Option(names = {"-C", "--id-column-type"}, paramLabel = "<type>", defaultValue = "gml",
@CommandLine.Option(names = {"-C", "--id-column-type"}, paramLabel = "<type>", defaultValue = "resource",
description = "Type of id column value: ${COMPLETION-CANDIDATES} (default: ${DEFAULT-VALUE}).")
private Type type;

Expand All @@ -77,7 +77,7 @@ enum Type {gml, db}

public DeleteListParser toDeleteListParser() {
DeleteListParser parser = new DeleteListParser(file)
.withIdType(type == Type.db ? DeleteListParser.IdType.DATABASE_ID : DeleteListParser.IdType.GML_ID)
.withIdType(type == Type.db ? DeleteListParser.IdType.DATABASE_ID : DeleteListParser.IdType.RESOURCE_ID)
.withHeader(header)
.withDelimiter(delimiter)
.withQuoteChar(quote.charAt(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ImportFilter toImportFilter() {

if (idOption != null) {
SimpleAttributeFilter attributeFilter = new SimpleAttributeFilter();
attributeFilter.setGmlIdFilter(idOption.toResourceIdOperator());
attributeFilter.setResourceIdFilter(idOption.toResourceIdOperator());
importFilter.setAttributeFilter(attributeFilter);
importFilter.setUseAttributeFilter(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public SimpleKmlQuery toSimpleKmlQuery() {
if (resourceIdOption != null) {
ResourceIdOperator idOperator = resourceIdOption.toResourceIdOperator();
if (idOperator != null) {
query.setUseGmlIdFilter(true);
query.setGmlIdFilter(idOperator);
query.setUseResourceIdFilter(true);
query.setResourceIdFilter(idOperator);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,62 @@
package org.citydb.gui.components.dialog;

import org.citydb.config.i18n.Language;
import org.citydb.gui.util.GuiUtil;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

public class ConfirmationCheckDialog {
private final Component parent;
private final String title;
private final int optionType;
private final int messageType;
private final List<Object> messages;
private final JCheckBox disableDialog;

private JPanel content;
private JCheckBox disableDialog;
private Component parent;
private int messageType;
private int optionType;
private String title;

public ConfirmationCheckDialog(Component parent, String title, Component message, int optionType, int messageType) {
this.parent = parent;
this.title = title;
this.optionType = optionType;
this.messageType = messageType;

initGui(message);
private ConfirmationCheckDialog() {
messages = new ArrayList<>();
disableDialog = new JCheckBox(Language.I18N.getString("common.dialog.msg.noShow"));
}

public ConfirmationCheckDialog(Component parent, String title, Component message, int optionType) {
this(parent, title, message, optionType, JOptionPane.QUESTION_MESSAGE);
public static ConfirmationCheckDialog defaults() {
ConfirmationCheckDialog dialog = new ConfirmationCheckDialog();
dialog.messageType = JOptionPane.QUESTION_MESSAGE;
dialog.optionType = JOptionPane.YES_NO_CANCEL_OPTION;
return dialog;
}

public ConfirmationCheckDialog(Component parent, String title, Component message) {
this(parent, title, message, JOptionPane.YES_NO_CANCEL_OPTION);
public ConfirmationCheckDialog withParentComponent(Component parent) {
this.parent = parent;
return this;
}

public ConfirmationCheckDialog(Component parent, String title, String message, int optionType, int messageType) {
this(parent, title, new JLabel(message), optionType, messageType);
public ConfirmationCheckDialog withMessageType(int messageType) {
this.messageType = messageType;
return this;
}

public ConfirmationCheckDialog(Component parent, String title, String message, int optionType) {
this(parent, title, message, optionType, JOptionPane.QUESTION_MESSAGE);
public ConfirmationCheckDialog withOptionType(int optionType) {
this.optionType = optionType;
return this;
}

public ConfirmationCheckDialog(Component parent, String title, String message) {
this(parent, title, message, JOptionPane.YES_NO_CANCEL_OPTION);
public ConfirmationCheckDialog withTitle(String title) {
this.title = title;
return this;
}

private void initGui(Component message) {
content = new JPanel(new GridBagLayout());
disableDialog = new JCheckBox(Language.I18N.getString("common.dialog.msg.noShow"));

content.add(message, GuiUtil.setConstraints(0, 0, 1, 0, GridBagConstraints.BOTH, 0, 0, 0, 0));
content.add(disableDialog, GuiUtil.setConstraints(0, 1, 1, 0, GridBagConstraints.BOTH, 10, 0, 0, 0));
public ConfirmationCheckDialog addMessage(Object message) {
messages.add(message);
return this;
}

public int show() {
return JOptionPane.showConfirmDialog(parent, content, title, optionType, messageType);
messages.add("\n");
messages.add(disableDialog);
return JOptionPane.showConfirmDialog(parent, messages.toArray(), title, optionType, messageType);
}

public boolean keepShowingDialog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public XSLTransformationPanel(boolean isExport, Config config) {

@Override
public boolean isModified() {
XSLTransformation transformation = isExport ? config.getExportConfig().getXSLTransformation() :
config.getImportConfig().getXSLTransformation();
XSLTransformation transformation = isExport ?
config.getExportConfig().getCityGMLOptions().getXSLTransformation() :
config.getImportConfig().getCityGMLOptions().getXSLTransformation();

if (transformation.isEnabled() != applyStylesheets.isSelected()) return true;
if (!transformation.isSetStylesheets() && !first.stylesheet.getText().trim().isEmpty()) return true;
Expand Down Expand Up @@ -114,8 +115,8 @@ private void initGui() {
@Override
public void setSettings() {
XSLTransformation transformation = isExport ?
config.getExportConfig().getXSLTransformation() :
config.getImportConfig().getXSLTransformation();
config.getExportConfig().getCityGMLOptions().getXSLTransformation() :
config.getImportConfig().getCityGMLOptions().getXSLTransformation();

transformation.setEnabled(applyStylesheets.isSelected());

Expand Down Expand Up @@ -158,8 +159,8 @@ public void setSettings() {
@Override
public void loadSettings() {
XSLTransformation transformation = isExport ?
config.getExportConfig().getXSLTransformation() :
config.getImportConfig().getXSLTransformation();
config.getExportConfig().getCityGMLOptions().getXSLTransformation() :
config.getImportConfig().getCityGMLOptions().getXSLTransformation();

applyStylesheets.setSelected(transformation.isEnabled());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
public class AttributeFilterView extends FilterView {
private JPanel component;

private JLabel gmlIdLabel;
private JTextField gmlIdText;
private JLabel gmlNameLabel;
private JTextField gmlNameText;
private JLabel resourceIdLabel;
private JTextField resourceIdText;
private JLabel nameLabel;
private JTextField nameText;
private JLabel lineageLabel;
private JTextField lineageText;

Expand All @@ -59,42 +59,42 @@ private void init() {
component = new JPanel();
component.setLayout(new GridBagLayout());

gmlIdLabel = new JLabel();
gmlIdText = new JTextField();
gmlNameLabel = new JLabel();
gmlNameText = new JTextField();
resourceIdLabel = new JLabel();
resourceIdText = new JTextField();
nameLabel = new JLabel();
nameText = new JTextField();
lineageLabel = new JLabel();
lineageText = new JTextField();

// gml:id filter
component.add(gmlIdLabel, GuiUtil.setConstraints(0, 0, 0, 0, GridBagConstraints.HORIZONTAL, 10, 0, 5, 5));
component.add(gmlIdText, GuiUtil.setConstraints(1, 0, 1, 0, GridBagConstraints.HORIZONTAL, 10, 5, 5, 0));
// resource id filter
component.add(resourceIdLabel, GuiUtil.setConstraints(0, 0, 0, 0, GridBagConstraints.HORIZONTAL, 10, 0, 5, 5));
component.add(resourceIdText, GuiUtil.setConstraints(1, 0, 1, 0, GridBagConstraints.HORIZONTAL, 10, 5, 5, 0));

// gml:name filter
component.add(gmlNameLabel, GuiUtil.setConstraints(0, 1, 0, 0, GridBagConstraints.HORIZONTAL, 0, 0, 5, 5));
component.add(gmlNameText, GuiUtil.setConstraints(1, 1, 1, 0, GridBagConstraints.HORIZONTAL, 0, 5, 5, 0));
// name filter
component.add(nameLabel, GuiUtil.setConstraints(0, 1, 0, 0, GridBagConstraints.HORIZONTAL, 0, 0, 5, 5));
component.add(nameText, GuiUtil.setConstraints(1, 1, 1, 0, GridBagConstraints.HORIZONTAL, 0, 5, 5, 0));

// citydb:lineage filter
component.add(lineageLabel, GuiUtil.setConstraints(0, 2, 0, 0, GridBagConstraints.HORIZONTAL, 0, 0, 0, 5));
component.add(lineageText, GuiUtil.setConstraints(1, 2, 1, 0, GridBagConstraints.HORIZONTAL, 0, 5, 0, 0));

PopupMenuDecorator.getInstance().decorate(gmlNameText, gmlIdText, lineageText);
PopupMenuDecorator.getInstance().decorate(nameText, resourceIdText, lineageText);
}


@Override
public void doTranslation() {
gmlIdLabel.setText(Language.I18N.getString("filter.label.gmlId"));
gmlNameLabel.setText(Language.I18N.getString("filter.label.gmlName"));
resourceIdLabel.setText(Language.I18N.getString("filter.label.id"));
nameLabel.setText(Language.I18N.getString("filter.label.name"));
lineageLabel.setText(Language.I18N.getString("filter.label.lineage"));
}

@Override
public void setEnabled(boolean enable) {
gmlIdLabel.setEnabled(enable);
gmlIdText.setEnabled(enable);
gmlNameLabel.setEnabled(enable);
gmlNameText.setEnabled(enable);
resourceIdLabel.setEnabled(enable);
resourceIdText.setEnabled(enable);
nameLabel.setEnabled(enable);
nameText.setEnabled(enable);
lineageLabel.setEnabled(enable);
lineageText.setEnabled(enable);
}
Expand Down Expand Up @@ -123,13 +123,13 @@ public Icon getIcon() {
public void loadSettings() {
SimpleQuery query = simpleQuerySupplier.get();

// gml:id filter
ResourceIdOperator gmlIdFilter = query.getSelectionFilter().getGmlIdFilter();
gmlIdText.setText(String.join(",", gmlIdFilter.getResourceIds()));
// resource id filter
ResourceIdOperator resourceIdFilter = query.getSelectionFilter().getResourceIdFilter();
resourceIdText.setText(String.join(",", resourceIdFilter.getResourceIds()));

// gml:name
LikeOperator gmlNameFilter = query.getSelectionFilter().getGmlNameFilter();
gmlNameText.setText(gmlNameFilter.getLiteral());
// name
LikeOperator nameFilter = query.getSelectionFilter().getNameFilter();
nameText.setText(nameFilter.getLiteral());

// citydb:lineage
LikeOperator lineageFilter = query.getSelectionFilter().getLineageFilter();
Expand All @@ -140,19 +140,19 @@ public void loadSettings() {
public void setSettings() {
SimpleQuery query = simpleQuerySupplier.get();

// gml:id filter
ResourceIdOperator gmlIdFilter = query.getSelectionFilter().getGmlIdFilter();
gmlIdFilter.reset();
if (!gmlIdText.getText().trim().isEmpty()) {
String trimmed = gmlIdText.getText().replaceAll("\\s+", "");
gmlIdFilter.setResourceIds(Util.string2string(trimmed, ","));
// resource id filter
ResourceIdOperator resourceIdFilter = query.getSelectionFilter().getResourceIdFilter();
resourceIdFilter.reset();
if (!resourceIdText.getText().trim().isEmpty()) {
String trimmed = resourceIdText.getText().replaceAll("\\s+", "");
resourceIdFilter.setResourceIds(Util.string2string(trimmed, ","));
}

// gml:name
LikeOperator gmlNameFilter = query.getSelectionFilter().getGmlNameFilter();
gmlNameFilter.reset();
if (!gmlNameText.getText().trim().isEmpty())
gmlNameFilter.setLiteral(gmlNameText.getText().trim());
// name
LikeOperator nameFilter = query.getSelectionFilter().getNameFilter();
nameFilter.reset();
if (!nameText.getText().trim().isEmpty())
nameFilter.setLiteral(nameText.getText().trim());

// citydb:lineage
LikeOperator lineageFilter = query.getSelectionFilter().getLineageFilter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ else if (featureVersionFilter.isSetStartDate()
SimpleSelectionFilter selectionFilter = simpleQuery.getSelectionFilter();

if (!selectionFilter.isUseSQLFilter()) {
if (selectionFilter.isSetGmlIdFilter() && selectionFilter.getGmlIdFilter().isSetResourceIds())
predicates.add(selectionFilter.getGmlIdFilter());
if (selectionFilter.isSetResourceIdFilter() && selectionFilter.getResourceIdFilter().isSetResourceIds())
predicates.add(selectionFilter.getResourceIdFilter());

if (selectionFilter.isSetGmlNameFilter() && selectionFilter.getGmlNameFilter().isSetLiteral()) {
LikeOperator nameFilter = selectionFilter.getGmlNameFilter();
if (selectionFilter.isSetNameFilter() && selectionFilter.getNameFilter().isSetLiteral()) {
LikeOperator nameFilter = selectionFilter.getNameFilter();
nameFilter.setValueReference("gml:name");
predicates.add(nameFilter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ private void doOperation() {
if (changeSrid && config.getGuiConfig().isShowChangeSridWarning()) {
JPanel confirmPanel = new JPanel(new GridBagLayout());

JLabel headerLabel = new JLabel(Language.I18N.getString("db.dialog.srs.changeSrid"));
JLabel sridLabel = new JLabel(Language.I18N.getString("pref.db.srs.label.srid") + ":");
JLabel sridValue = new JLabel(String.valueOf(srs.getSrid()));
JLabel geometriesLabel = new JLabel(Language.I18N.getString("db.label.operation.srs.geometries") + ":");
Expand All @@ -298,15 +297,16 @@ private void doOperation() {
sridValue.setFont(sridValue.getFont().deriveFont(Font.BOLD));
geometriesValue.setFont(sridValue.getFont());

confirmPanel.add(headerLabel, GuiUtil.setConstraints(0, 0, 2, 1, 1, 0, GridBagConstraints.HORIZONTAL, 0, 0, 0, 0));
confirmPanel.add(sridLabel, GuiUtil.setConstraints(0, 1, 0, 0, GridBagConstraints.HORIZONTAL, 10, 0, 0, 0));
confirmPanel.add(sridValue, GuiUtil.setConstraints(1, 1, 1, 0, GridBagConstraints.HORIZONTAL, 10, 5, 0, 0));
confirmPanel.add(geometriesLabel, GuiUtil.setConstraints(0, 2, 0, 0, GridBagConstraints.HORIZONTAL, 5, 0, 0, 0));
confirmPanel.add(geometriesValue, GuiUtil.setConstraints(1, 2, 1, 0, GridBagConstraints.HORIZONTAL, 5, 5, 0, 0));
confirmPanel.add(sridLabel, GuiUtil.setConstraints(0, 0, 0, 0, GridBagConstraints.HORIZONTAL, 10, 0, 0, 0));
confirmPanel.add(sridValue, GuiUtil.setConstraints(1, 0, 1, 0, GridBagConstraints.HORIZONTAL, 10, 5, 0, 0));
confirmPanel.add(geometriesLabel, GuiUtil.setConstraints(0, 1, 0, 0, GridBagConstraints.HORIZONTAL, 5, 0, 0, 0));
confirmPanel.add(geometriesValue, GuiUtil.setConstraints(1, 1, 1, 0, GridBagConstraints.HORIZONTAL, 5, 5, 0, 0));

ConfirmationCheckDialog dialog = new ConfirmationCheckDialog(viewController.getTopFrame(),
Language.I18N.getString("db.dialog.srs.window"),
confirmPanel);
ConfirmationCheckDialog dialog = ConfirmationCheckDialog.defaults()
.withParentComponent(viewController.getTopFrame())
.withTitle(Language.I18N.getString("db.dialog.srs.window"))
.addMessage(Language.I18N.getString("db.dialog.srs.changeSrid") + "\n")
.addMessage(confirmPanel);

int result = dialog.show();
config.getGuiConfig().setShowChangeSridWarning(dialog.keepShowingDialog());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,11 @@ public boolean showWarning(DatabaseConnectionWarning warning) {
}

if (showWarning) {
ConfirmationCheckDialog dialog = new ConfirmationCheckDialog(viewController.getTopFrame(),
Language.I18N.getString("db.dialog.warn.title"),
warning.getFormattedMessage(),
JOptionPane.OK_CANCEL_OPTION);
ConfirmationCheckDialog dialog = ConfirmationCheckDialog.defaults()
.withParentComponent(viewController.getTopFrame())
.withOptionType(JOptionPane.OK_CANCEL_OPTION)
.withTitle(Language.I18N.getString("db.dialog.warn.title"))
.addMessage(warning.getFormattedMessage());

option = dialog.show();
if (!dialog.keepShowingDialog()) {
Expand Down
Loading