View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2015 VoyagerSearch
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Apache License, Version 2.0 which
5    * accompanies this distribution and is available at
6    *    http://www.apache.org/licenses/LICENSE-2.0.txt
7    ******************************************************************************/
8   
9   package org.locationtech.spatial4j.io.jts;
10  
11  import org.locationtech.spatial4j.context.jts.JtsSpatialContext;
12  import org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory;
13  import org.locationtech.spatial4j.io.WKTWriter;
14  import org.locationtech.spatial4j.shape.Shape;
15  import org.locationtech.spatial4j.shape.jts.JtsGeometry;
16  
17  /**
18   * Writes the WKT using JTS directly
19   */
20  public class JtsWKTWriter extends WKTWriter {
21  
22    public JtsWKTWriter(JtsSpatialContext ctx, JtsSpatialContextFactory factory) {
23  
24    }
25  
26    @Override
27    public String toString(Shape shape) {
28      if (shape instanceof JtsGeometry) {
29        return ((JtsGeometry) shape).getGeom().toText();
30      }
31      return super.toString(shape);
32    }
33  }