Skip to content

aleksey-stukalov/sample-gis-datatypes

Repository files navigation

sample-gis-datatypes

The application extends standard CUBA datatypes with geo-specific types from the opensource JTS Topology Suite:

  1. Point
  2. LineString
  3. Polygon
  4. Multi Polygon

Using JTS your CUBA application amplifies its power with Geometric functions, Spatial structures and algorithms and I/O capabilities, coming along with the topology suite. So, your application has all essential features to become a full-scale geographic information system.

screenshot

Adding a Custom Datatype

General information on datatypes is available in the corresponding section of the official platform manual. You can find implementation of geo types in this folder of the project. They are also declared in the metadata.xml file.

This project demonstrates the process of storing and reading a complex datatype such as geo objects. So, while persisting the objects are converted to the WKT format and persisted as text. While reading this text will be parsed back into the objects, so that you can work with them normally from the source code. Such behaviour is achieved by using JPA converters. The converters should also be registered in the persistence.xml file.

To apply the converters for a field it should be annotated with the @Convert(converter = SomeConverter.class) annotation. See the location field of the Port entity in the sample project as an example:

public class Port extends StandardEntity {
    
    ...
    
    @Convert(converter = CubaPointWKTConverter.class)
    @MetaProperty(datatype = PointDatatype.NAME, mandatory = true)
    @Column(name = "LOCATION", nullable = false)
    protected Point location;
    
    ...
    
    public Point getLocation() {
        return location;
    }

    public void setLocation(Point location) {
        this.location = location;
    }
    
    ...
    
}

DBMS support

  • Datatypes are not DB independent. To specify SQL type which should be used with another DBMS - add additional @Ddl annotations to the data type definitions in the com.company.cruisesample.gis.datatypes package:
@Ddl(dbms = "postgres", value = "geometry")
@Ddl(dbms = "mydbms", value = "dbms-specific SQL type")
public class PointDatatype implements Datatype<Point> {
...
}

About

The application demonstrates how a custom datatype can be added to a CUBA application.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages