Class Projection

java.lang.Object
smile.plot.vega.Projection

public class Projection extends Object
The geographic projection, which will be applied to shape path for "geoshape" marks and to latitude and "longitude" channels for other marks. A cartographic projection maps longitude and latitude pairs to x, y coordinates. As with Vega, one can use projections in Vega-Lite to lay out both geographic points (such as locations on a map) represented by longitude and latitude coordinates, or to project geographic regions (such as countries and states) represented using the GeoJSON format. Projections are specified at the unit specification level, alongside encoding. Geographic coordinate data can then be mapped to longitude and latitude channels (and longitude2 and latitude2 for ranged marks).
  • Method Summary

    Modifier and Type
    Method
    Description
    center(double longitude, double latitude)
    Sets the projection's center, a two-element array of longitude and latitude in degrees.
    clipAngle(double angle)
    Sets the projection's clipping circle radius to the specified angle in degrees.
    clipExtent(double x0, double y0, double x1, double y1)
    Sets the projection's viewport clip extent to the specified bounds in pixels.
    parallels(double... parallels)
    For conic projections, sets the two standard parallels that define the map layout.
    pointRadius(double radius)
    Sets the default radius (in pixels) to use when drawing GeoJSON Point and MultiPoint geometries.
    precision(double threshold)
    Sets the threshold for the projection's adaptive resampling to the specified value in pixels.
    rotate(double lambda, double phi, double gamma)
    Sets the projection's three-axis rotation to the specified angles by specifying the rotation angles in degrees about each spherical axis.
    scale(double scale)
    Sets the projection's scale (zoom) factor, overriding automatic fitting.
    Returns the specification in pretty print.
     
    translate(double tx, double ty)
    Sets the projection's translation offset.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toPrettyString

      public String toPrettyString()
      Returns the specification in pretty print.
      Returns:
      the specification in pretty print.
    • center

      public Projection center(double longitude, double latitude)
      Sets the projection's center, a two-element array of longitude and latitude in degrees.
      Parameters:
      longitude - longitude in degrees.
      latitude - latitude in degrees.
      Returns:
      this object.
    • clipAngle

      public Projection clipAngle(double angle)
      Sets the projection's clipping circle radius to the specified angle in degrees.
      Parameters:
      angle - The clip angle in degrees.
      Returns:
      this object.
    • clipExtent

      public Projection clipExtent(double x0, double y0, double x1, double y1)
      Sets the projection's viewport clip extent to the specified bounds in pixels. The extent bounds are specified as [x0, y0] and [x1, y1].
      Parameters:
      x0 - the left of the viewport.
      y0 - the top of the viewport.
      x1 - the right of the viewport.
      y1 - the bottom of the viewport.
      Returns:
      this object.
    • parallels

      public Projection parallels(double... parallels)
      For conic projections, sets the two standard parallels that define the map layout.
      Parameters:
      parallels - two standard parallels.
      Returns:
      this object.
    • pointRadius

      public Projection pointRadius(double radius)
      Sets the default radius (in pixels) to use when drawing GeoJSON Point and MultiPoint geometries.
      Parameters:
      radius - the fill color.
      Returns:
      this object.
    • precision

      public Projection precision(double threshold)
      Sets the threshold for the projection's adaptive resampling to the specified value in pixels. This value corresponds to the Douglas–Peucker distance.
      Parameters:
      threshold - the threshold.
      Returns:
      this object.
    • rotate

      public Projection rotate(double lambda, double phi, double gamma)
      Sets the projection's three-axis rotation to the specified angles by specifying the rotation angles in degrees about each spherical axis.
      Parameters:
      lambda - correspond to yaw.
      phi - correspond to pitch.
      gamma - correspond to roll.
      Returns:
      this object.
    • scale

      public Projection scale(double scale)
      Sets the projection's scale (zoom) factor, overriding automatic fitting. The default scale is projection-specific. The scale factor corresponds linearly to the distance between projected points; however, scale factor values are not equivalent across projections.
      Parameters:
      scale - the scale factor.
      Returns:
      this object.
    • translate

      public Projection translate(double tx, double ty)
      Sets the projection's translation offset.
      Parameters:
      tx - the offset in x-axis.
      ty - the offset in y-axis.
      Returns:
      this object.