GRASS
Class Categories

java.lang.Object
  |
  +--GRASS.Categories

public class Categories
extends java.lang.Object

This class wraps GRASS library struct Categories (Raster Histogram). Categories is not documented in the GRASS 4.2 Programmer's Manual, but see Section 12.10.2 Raster Categoriy File to learn about routines that deal with struct Categories.


Constructor Summary
Categories(int n, java.lang.String title)
          Constructs an empty object, allocates memory and initializes GRASS struct Categories.
 
Method Summary
 java.lang.String G_get_cat(int cat)
          This method looks up category n and returns a string which is the label for the category.
 java.lang.String G_get_cats_title()
          Gets title from this category structure.
 void G_set_cat(int cat, java.lang.String label)
          The label is copied into the cats structure for category n.
 void G_set_cats_title(java.lang.String title)
          Sets the title of this Categories structure.
 void G_write_cats(java.lang.String name)
          Writes the category file for the raster file name in the current mapset.
 void G_write_vector_cats(java.lang.String name)
          Writes the category file for the vector file name in the current mapset.
 int num()
          Returns the value of Categories->num field in struct Categories.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Categories

public Categories(int n,
                  java.lang.String title)
Constructs an empty object, allocates memory and initializes GRASS struct Categories.
Method Detail

num

public int num()
Returns the value of Categories->num field in struct Categories. Probably it is the highest category number.
Returns:
value of Categories->num (highest category number?)

G_write_cats

public void G_write_cats(java.lang.String name)
                  throws GRASSException
Writes the category file for the raster file name in the current mapset. Wraps GRASS library routine
 G_write_cats (name, cats)
     char *name;
     struct Categories *cats;
 
See the GRASS 4.2 Programmer's Manual, Section 12.10.2.1. Reading and Writing the Raster Category File
Parameters:
name - raster layer name
Throws:
GRASSException - is thrown with an appropriate message if there was an error reading category file

G_write_vector_cats

public void G_write_vector_cats(java.lang.String name)
                         throws GRASSException
Writes the category file for the vector file name in the current mapset. Wraps GRASS library routine
 G_write_cats (name, cats)
     char *name;
     struct Categories *cats;
 
See the GRASS 4.2 Programmer's Manual, Section 12.11.6 Vector Category File
Parameters:
name - vector layer name
Throws:
GRASSException - is thrown with an appropriate message if there was an error reading category file

G_get_cat

public java.lang.String G_get_cat(int cat)
This method looks up category n and returns a string which is the label for the category. If the category does not exist in cats, then an empty string "" is returned. Wraps GRASS library routine:
 char *
 G_get_cat (n, cats)
    CELL n;
    struct Categories *cats;
 
See the GRASS 4.2 Programmer's Manual, Section 12.10.2.2 Querying and Changing the Categories Structure
Parameters:
n - category value to look label for
Returns:
category label or empty string if category does not exist

G_get_cats_title

public java.lang.String G_get_cats_title()
Gets title from this category structure. Wraps GRASS library function.
 char*
 G_get_cell_title(cats)
     struct Categories *cats;
 
See the GRASS 4.2 Programmer's Manual, Section 12.10.2.2. Querying and Changing the Categories Structure
Returns:
categories title

G_set_cats_title

public void G_set_cats_title(java.lang.String title)
Sets the title of this Categories structure.
 G_set_cats_title (title, cats)
    char *title;
    struct Categories *cats;
 
See the GRASS 4.2 Programmer's Manual, Section 12.10.2.2. Querying and Changing the Categories Structure
Parameters:
title - title to set

G_set_cat

public void G_set_cat(int cat,
                      java.lang.String label)
The label is copied into the cats structure for category n. Wraps GRASS library routine:
 G_set_cat (n, label, cats)
     CELL n;
     char *label;
     struct Categories *cats;
 
See the GRASS 4.2 Programmer's Manual, Section 12.10.2.2.Querying and Changing the Categories Structure
Parameters:
cat - category to modify
label - new category label

toString

public java.lang.String toString()
Returns a string representation of the object.
Returns:
String that represents this object
Overrides:
toString in class java.lang.Object


GRASS-JNI Home Page