Skip to content

Commit

Permalink
Merge pull request #166 from 3dcitydb/cityjson-support
Browse files Browse the repository at this point in the history
CityJSON export
  • Loading branch information
clausnagel authored Feb 2, 2021
2 parents f007534 + 4ff5862 commit 091a639
Show file tree
Hide file tree
Showing 234 changed files with 2,855 additions and 1,672 deletions.
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);

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

0 comments on commit 091a639

Please sign in to comment.