Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
ol3-wrapper.iml
*.iml
target
.classpath
.project
.settings
2 changes: 1 addition & 1 deletion gwt-ol3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--<vaadin.version>7.7.6</vaadin.version>-->
<vaadin.version>8.6.0</vaadin.version>
<vaadin.version>8.12.2</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>

<!-- ZIP Manifest fields -->
Expand Down
4 changes: 2 additions & 2 deletions v-ol3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!--<vaadin.version>7.7.6</vaadin.version>-->
<vaadin.version>8.6.0</vaadin.version>
<vaadin.version>8.12.2</vaadin.version>

<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>

Expand All @@ -25,7 +25,7 @@
<Implementation-Title>${project.name}</Implementation-Title>
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
<Vaadin-License-Title>Apache License 2.0</Vaadin-License-Title>
<Vaadin-Addon>${artifactId}-${project.version}.jar</Vaadin-Addon>
<Vaadin-Addon>${project.artifactId}-${project.version}.jar</Vaadin-Addon>
<skipTests>true</skipTests>
</properties>

Expand Down
39 changes: 24 additions & 15 deletions v-ol3/src/main/java/org/vaadin/addon/vol3/client/OLCoordinate.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@
/**
* Models a coordinate in some projection units
*/
public class OLCoordinate implements Serializable{
public class OLCoordinate implements Serializable {
private static final long serialVersionUID = 1L;

public OLCoordinate(){
x=0.0;
y=0.0;
}
public double x;
public double y;

public OLCoordinate() {
x = 0.0;
y = 0.0;
}

public Double x;
public Double y;
public OLCoordinate(double lon, double lat) {
x = lon;
y = lat;
}

public OLCoordinate(double xCoord, double yCoord){
x=xCoord;
y=yCoord;
}
public double getLon() {
return x;
}

@Override
public String toString() {
return "OLCoordinate{" + "x=" + x +", y=" + y +"}";
}
public double getLat() {
return y;
}

@Override
public String toString() {
return "OLCoordinate{" + "x=" + x + ", y=" + y + "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void init(OLCoordinate first) {
minX = first.x;
minY = first.y;
maxX = first.x;
minY = first.y;
maxY = first.y;
empty = false;
}

Expand Down Expand Up @@ -78,7 +78,7 @@ public void extend(OLExtent extent) {
}

public OLCoordinate getCenter() {
return new OLCoordinate((maxX-minX)/2, (maxY-minY)/2);
return new OLCoordinate((maxX+minX)/2, (maxY+minY)/2);
}

public double[] toArray() {
Expand All @@ -99,4 +99,8 @@ public String toString() {
public boolean contains(Double x, Double y) {
return minX <= x && maxX >= x && minY <= y && maxY >= y;
}

public boolean isEmpty() {
return empty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void execute() {

private void updateSelectedFeatures(){
List<String> selectedFeatures=new ArrayList<String>();
Collection collection=interaction.getFeatures();
Collection<Feature> collection=interaction.getFeatures();
for(int i=0;i<collection.getLength();i++){
Feature f=collection.item(i).cast();
selectedFeatures.add(f.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
*/
@Connect(OLImageWMSSource.class)
public class OLImageWMSSourceConnector extends OLSourceConnector implements HasFeatureInfoUrl{
private ImageWMSSource source;
private static final long serialVersionUID = 1L;
//private ImageWMSSource source;

@Override
protected Source createSource() {
Expand All @@ -46,7 +47,7 @@ protected Source createSource() {
options.setLogo(state.logo);
}
if(state.params!=null){
FastStringMap map = (FastStringMap) FastStringMap.createObject();
FastStringMap<String> map = FastStringMap.create();
Set<Map.Entry<String, String>> entries = state.params.entrySet();
for(Map.Entry<String,String> entry : entries){
map.put(entry.getKey(),entry.getValue());
Expand Down Expand Up @@ -93,7 +94,7 @@ public ImageWMSSource getSource() {
}

private void updateParams(){
FastStringMap map = (FastStringMap) FastStringMap.createObject();
FastStringMap<String> map = FastStringMap.create();
Set<Map.Entry<String, String>> entries = getState().params.entrySet();
for(Map.Entry<String,String> entry : entries){
map.put(entry.getKey(),entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected Source createSource() {
options.setMaxZoom(state.maxZoom);
}
if(state.params!=null){
FastStringMap map = (FastStringMap) FastStringMap.createObject();
FastStringMap<String> map = FastStringMap.create();
Set<Map.Entry<String, String>> entries = state.params.entrySet();
for(Map.Entry<String,String> entry : entries){
map.put(entry.getKey(),entry.getValue());
Expand Down Expand Up @@ -132,7 +132,7 @@ public TileWMSSource getSource() {
}

private void updateParams(){
FastStringMap map = (FastStringMap) FastStringMap.createObject();
FastStringMap<String> map = FastStringMap.create();
Set<Map.Entry<String, String>> entries = getState().params.entrySet();
for(Map.Entry<String,String> entry : entries){
map.put(entry.getKey(),entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.vaadin.addon.vol3.feature;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

Expand All @@ -14,6 +15,12 @@ public OLGeometry(T... elements){
this.elements.add(element);
}
}

public OLGeometry(Collection<T> elements){
for(T element : elements){
this.elements.add(element);
}
}

public void add(T element){
this.elements.add(element);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.vaadin.addon.vol3.feature;

import java.util.Collection;

/**
* Geometry consisting of multiple points
*/
Expand All @@ -8,4 +10,8 @@ public class OLMultiPoint extends OLGeometry<OLPoint> {
public OLMultiPoint(OLPoint ... points){
super(points);
}

public OLMultiPoint(Collection<OLPoint> points){
super(points);
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
package org.vaadin.addon.vol3.demoandtestapp;

import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.Notification;
import java.util.List;
import java.util.logging.Logger;

import org.vaadin.addon.vol3.OLMap;
import org.vaadin.addon.vol3.feature.OLFeature;
import org.vaadin.addon.vol3.interaction.OLDrawInteraction;
import org.vaadin.addon.vol3.interaction.OLDrawInteractionOptions;
import org.vaadin.addon.vol3.interaction.OLDrawInteractionOptions.DrawingType;
import org.vaadin.addon.vol3.interaction.OLInteraction;
import org.vaadin.addon.vol3.interaction.OLModifyInteraction;
import org.vaadin.addon.vol3.interaction.OLModifyInteractionOptions;
import org.vaadin.addon.vol3.interaction.OLSelectInteraction;
import org.vaadin.addon.vol3.source.OLVectorSource;

import java.util.List;
import java.util.logging.Logger;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.Notification;

/**
* Map for testing interactions
*/
public class InteractionMap extends VectorLayerMap {
private static final long serialVersionUID = 1L;

private NativeSelect markerType;
private NativeSelect<DrawingType> markerType;
private static final Logger logger= Logger.getLogger(InteractionMap.class.getName());
public List<String> selection;

Expand Down Expand Up @@ -50,46 +53,36 @@ private void clearInteractions(){
protected AbstractLayout createControls() {
AbstractLayout layout= super.createControls();
Button selectButton=new Button("selectMode");
selectButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
selectButton.addClickListener(e -> {
clearInteractions();
map.addInteraction(createSelectInteraction());
}
});
});
layout.addComponent(selectButton);

Button modifyButton=new Button("modifyMode");
modifyButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
modifyButton.addClickListener(e -> {

clearInteractions();
//logger.info(((OLVectorSource) vectorLayer.getSource()).getFeatures().toString());
logger.fine(((OLVectorSource) vectorLayer.getSource()).getFeatures().toString());
map.addInteraction(createModifyInteraction());
}
});

});
layout.addComponent(modifyButton);

Button modifyRectButton=new Button("modifyOnlyRectFeature");
modifyRectButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
modifyRectButton.addClickListener(e -> {
clearInteractions();
map.addInteraction(createModifyRectInteraction());
}
});
});
layout.addComponent(modifyRectButton);

Button drawButton=new Button("drawMode");
drawButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
drawButton.addClickListener(e -> {
clearInteractions();
map.addInteraction(createDrawInteraction());
}
});
});
layout.addComponent(drawButton);
markerType=new NativeSelect();
markerType=new NativeSelect<>();
markerType.setItems(OLDrawInteractionOptions.DrawingType.POINT,
OLDrawInteractionOptions.DrawingType.LINESTRING,
OLDrawInteractionOptions.DrawingType.POLYGON);
Expand All @@ -116,18 +109,15 @@ public void valueChange(Property.ValueChangeEvent event) {
*/
layout.addComponent(markerType);
Button deleteButton = new Button("delete selected");
deleteButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
deleteButton.addClickListener(e -> {
if(selection!=null){
OLVectorSource source = (OLVectorSource) vectorLayer.getSource();
for(String id : selection){
source.removeFeatureById(id);
}
selection.clear();
}
}
});
});
layout.addComponent(deleteButton);
return layout;
}
Expand Down Expand Up @@ -163,7 +153,7 @@ private OLModifyInteraction createModifyRectInteraction(){
// create modify interaction
OLModifyInteractionOptions modOpts=new OLModifyInteractionOptions();
OLFeature rectFeature = ((OLVectorSource) vectorLayer.getSource()).getFeatureById("rect");
//logger.info(rectFeature.toString());
logger.fine(rectFeature.toString());
OLModifyInteraction modify=new OLModifyInteraction(vectorLayer, modOpts, rectFeature);
return modify;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected OLMap createMap() {
protected OLFeature createPolygon(String id, double x, double y, double width, double height){
OLFeature testFeature=new OLFeature(id);
OLPolygon polygon = new OLPolygon();
List points = new ArrayList<OLCoordinate>();
List<OLCoordinate> points = new ArrayList<OLCoordinate>();
points.add(new OLCoordinate(x+width,y));
points.add(new OLCoordinate(x+width,y+height));
points.add(new OLCoordinate(x,y+height));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ protected OLFeature createMultipolygon(String id, double x, double y, double wid
OLFeature testFeature=new OLFeature(id);
OLMultiPolygon mpolygon=new OLMultiPolygon();
OLPolygon polygon = new OLPolygon();
List points = new ArrayList<OLCoordinate>();
List<OLCoordinate> points = new ArrayList<OLCoordinate>();
points.add(new OLCoordinate(x+width,y));
points.add(new OLCoordinate(x+width,y+height));
points.add(new OLCoordinate(x,y+height));
points.add(new OLCoordinate(x,y));
polygon.add(points);
mpolygon.add(polygon);
OLPolygon polygon2 = new OLPolygon();
List points2 = new ArrayList<OLCoordinate>();
List<OLCoordinate> points2 = new ArrayList<OLCoordinate>();
points2.add(new OLCoordinate(x-100d,y));
points2.add(new OLCoordinate(x-100d,y-50d));
points2.add(new OLCoordinate(x,y-50d));
Expand Down