Skip to content

Commit

Permalink
Start working on manual
Browse files Browse the repository at this point in the history
  • Loading branch information
jericks committed Oct 6, 2019
1 parent 45a1ba5 commit 7c38b8c
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ geo-shell.iml
geo-shell.log
dependency-reduced-pom.xml
examples/raster.tif.aux.xml
src/main/docs/output
75 changes: 75 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<asciidoctor.maven.plugin.version>1.5.7.1</asciidoctor.maven.plugin.version>
<asciidoctorj.version>1.6.1</asciidoctorj.version>
<asciidoctorj.pdf.version>1.5.0-alpha.16</asciidoctorj.pdf.version>
<jruby.version>9.2.5.0</jruby.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -205,6 +209,77 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>${asciidoctor.maven.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-pdf</artifactId>
<version>${asciidoctorj.pdf.version}</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>${jruby.version}</version>
</dependency>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj</artifactId>
<version>${asciidoctorj.version}</version>
</dependency>
</dependencies>
<configuration>
<sourceDirectory>src/main/docs</sourceDirectory>
</configuration>
<executions>
<execution>
<id>output-html</id>
<phase>package</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>html5</backend>
<sourceHighlighter>coderay</sourceHighlighter>
<relativeBaseDir>true</relativeBaseDir>
<imagesDir>./images</imagesDir>
<attributes>
<sourcedir>${project.basedir}/src/main/groovy</sourcedir>
<basedir>${project.basedir}/src/main/docs</basedir>
<imagesdir>./images</imagesdir>
<toc>left</toc>
<toclevels>4</toclevels>
<icons>font</icons>
<sectanchors>true</sectanchors>
<idprefix/>
<idseparator>-</idseparator>
<docinfo1>true</docinfo1>
</attributes>
</configuration>
</execution>
<execution>
<id>generate-pdf-doc</id>
<phase>package</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>pdf</backend>
<sourceHighlighter>rouge</sourceHighlighter>
<attributes>
<sourcedir>${project.basedir}/src/main/groovy</sourcedir>
<icons>font</icons>
<pagenums/>
<toc/>
<idprefix/>
<idseparator>-</idseparator>
</attributes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down
8 changes: 8 additions & 0 deletions src/main/docs/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
= geo-shell
Jared Erickson
v0.7-SNAPSHOT
ifndef::imagesdir[:imagesdir: images]

include::intro.adoc[]

include::workspace.adoc[]
20 changes: 20 additions & 0 deletions src/main/docs/intro.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ifndef::imagesdir[:imagesdir: images]

== Introduction

geo-shell is an interactive shell for geospatial analysis.

geo-shell has modules for dealing with *vectors*, *rasters*, *tiles*, *maps*, and *styles*.

For *vector* layers, you can use *workspace* commands access layers of spatial data
in datasets like shapefiles, geopackages, or postgis databases. With *layer* commands
you can perform geoprocessing functions like calculating centroids or buffer features.

For *raster* layers, you can use *format* commands access individual rasters from geotifs or world images.
With *raster* commands you can perform mosaic, raster algebra, or crop functions.

The *tile* commands let you create tile layers, get tiles, and get rasters from tiles.

The *style* commands let you create styles for vector layers and raster.

The *map* commands allow you to visualize vector, raster, and tile layers.
46 changes: 46 additions & 0 deletions src/main/docs/workspace.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ifndef::imagesdir[:imagesdir: images]

== Workspace

Workspaces hold vector layers. A Workspace can be a GeoPackage database,
a directory of Shapefiles, or a PostGIS database.

=== Basics

You can open, close, and list Workspaces. The eariest Workspace to open
is an in memory Workspace.

.Open a Workspace
include::output/workspace_basics_open_command.txt[]
include::output/workspace_basics_open_result.txt[]

You can open a Workspace with --params or connection parameters.
You can give it a name with --name flag.

.List open Workspaces
include::output/workspace_basics_list_command.txt[]
include::output/workspace_basics_list_result.txt[]

Listing open Workspaces give you the name and the type Workspace.

.Close a Workspace
include::output/workspace_basics_close_command.txt[]
include::output/workspace_basics_close_result.txt[]

Once you close a Workspace by name it will no longer appear with the list command.

=== Layers

In this example, we will open a GeoPackage database filled with data from Natural Earth.

.Open a Workspace
include::output/workspace_layers_open_command.txt[]
include::output/workspace_layers_open_result.txt[]

.List open Workspaces
include::output/workspace_layers_layers_command.txt[]
include::output/workspace_layers_layers_result.txt[]

.Close a Workspace
include::output/workspace_layers_close_command.txt[]
include::output/workspace_layers_close_result.txt[]
95 changes: 95 additions & 0 deletions src/test/groovy/org/geoshell/docs/WorkspaceDocTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package org.geoshell.docs

import org.junit.After
import org.junit.Before
import org.junit.Test
import org.springframework.shell.Bootstrap
import org.springframework.shell.core.CommandResult
import org.springframework.shell.core.JLineShellComponent

class WorkspaceDocTest {

private JLineShellComponent shell;

@Before
void before() throws InterruptedException {
Bootstrap bootstrap = new Bootstrap()
shell = bootstrap.getJLineShellComponent()
}

@After
void after() {
shell.stop()
}


@Test
void workspaceOpenListClose() {
run([
"workspace_basics_open": "workspace open --name mem --params memory",
"workspace_basics_list": "workspace list",
"workspace_basics_close": "workspace close --name mem"
])
}

@Test
void workspaceLayers() {
run([
"workspace_layers_open": "workspace open --name naturalearth --params src/test/resources/naturalearth.gpkg",
"workspace_layers_layers": "workspace layers --name naturalearth",
"workspace_layers_close": "workspace close --name naturalearth"
])
}

void run(Map<String,String> commands) {
commands.each { String name, String command ->
run(name, command)
}
}

String run(String name, String cmd) {
CommandResult result = shell.executeCommand(cmd)
writeFile("${name}_command", processCommand(cmd))
writeFile("${name}_result", processOutput(result.result.toString()))
}

void writeFile(String name, String text) {
File dir = new File("src/main/docs/output")
if (!dir.exists()) {
dir.mkdir()
}
File file = new File(dir, "${name}.txt")
file.text = text
}

String processCommand(String cmd) {

String name
String params

int firstParam = cmd.indexOf("--")
if (firstParam > -1) {
name = cmd.substring(0,firstParam).trim()
params = cmd.substring(firstParam).trim()
} else {
name = cmd.trim()
params = ""
}
String styledName = "[navy]*${name}*"
String styleParams = params.trim() == "" ? "" : params.split(" ").collect { String param ->
param = param.trim()
if (param.startsWith("--")) {
"[gray]#${param}#"
} else {
"[silver]#${param}#"
}
}.join(' ')

"[blue]#geo-shell># ${styledName} ${styleParams} +"
}

String processOutput(String output) {
output.split("\n").collect { "[green]#${it}# +" }.join("\n")
}

}
Binary file added src/test/resources/naturalearth.gpkg
Binary file not shown.

0 comments on commit 7c38b8c

Please sign in to comment.