View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2016 David Smiley
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;
10  
11  import org.locationtech.spatial4j.shape.Point;
12  import org.locationtech.spatial4j.shape.ShapeFactory;
13  
14  /** INTERNAL class used by some {@link ShapeReader}s. */
15  public class OnePointsBuilder implements ShapeFactory.PointsBuilder<OnePointsBuilder> {
16    private ShapeFactory shapeFactory;
17    private Point point;
18  
19    public OnePointsBuilder(ShapeFactory shapeFactory) {
20      this.shapeFactory = shapeFactory;
21    }
22  
23    @Override
24    public OnePointsBuilder pointXY(double x, double y) {
25      assert point == null;
26      point = shapeFactory.pointXY(x, y);
27      return this;
28    }
29  
30    @Override
31    public OnePointsBuilder pointXYZ(double x, double y, double z) {
32      assert point == null;
33      point = shapeFactory.pointXYZ(x, y, z);
34      return this;
35    }
36  
37    @Override
38    public OnePointsBuilder pointLatLon(double latitude, double longitude) {
39      assert point == null;
40      point = shapeFactory.pointLatLon(latitude, longitude);
41      return this;
42    }
43  
44    public Point getPoint() {
45      return point;
46    }
47  }