Skip to content

Commit

Permalink
Minor tweaks to the code.
Browse files Browse the repository at this point in the history
Base data exported compressed and added
  • Loading branch information
LupusUmbrae committed Apr 26, 2012
1 parent 355ad4e commit daa1468
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 211 deletions.
Binary file added resources/sql/base_data.rar
Binary file not shown.
16 changes: 14 additions & 2 deletions src/database/BuildDataSets.java
Expand Up @@ -38,13 +38,21 @@ public void buildDataSet(int size) throws SQLException {
currentLat = LAT_MIN;
currentLon = LON_MIN;
while (currentLat < LAT_MAX) {
Double startLat;
Double endLat;
startLat = currentLat;
endLat = currentLat + latLonStep;
while (currentLon < LON_MAX) {
dataTiles = new ArrayList<ArrayList<DataTile>>();

Double startLon;
Double endLon;
startLon = currentLon;
endLon = currentLon + latLonStep;

// Get the data

dataTiles = getData(currentLat, currentLat + latLonStep,
currentLon, currentLon + latLonStep, conn);
dataTiles = getData(startLat, endLat, startLon, endLon, conn);

DataTile tile = processTile(dataTiles, 1896, currentLat,
currentLon);
Expand Down Expand Up @@ -135,6 +143,10 @@ private DataTile processTile(ArrayList<ArrayList<DataTile>> tiles,
* @return
*/
private int calcSlopeRank(Double slope) {
if(slope < 0){
slope *= -1;
}

// (-0.5*(slope^2))+100
int rank = (int) (-0.5 * (Math.pow(slope, 2)) + 100);
return rank;
Expand Down
190 changes: 0 additions & 190 deletions src/database/buildDataSets.java

This file was deleted.

@@ -1,11 +1,13 @@
package database;
package database.threads;

import image.ImageProcess;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import database.DbConnection;

public class EnterBaseData implements Runnable {
private ImageProcess process;

Expand Down
Expand Up @@ -2,11 +2,11 @@

import database.BuildDataSets;

public class getPixelArea implements Runnable {
public class GetPixelArea implements Runnable {

private BuildDataSets set;

public getPixelArea(BuildDataSets set) {
public GetPixelArea(BuildDataSets set) {
this.set = set;
}

Expand Down
8 changes: 3 additions & 5 deletions src/image/ImageProcess.java
Expand Up @@ -8,9 +8,7 @@
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
Expand All @@ -22,7 +20,7 @@
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;

import database.EnterBaseData;
import database.threads.EnterBaseData;

public class ImageProcess {

Expand Down Expand Up @@ -167,8 +165,8 @@ private void convertRgb() throws Exception {
private void fillDb() throws IOException, SQLException,
InterruptedException {
File processedFileDir = new File(OUT_DIR + ROW_DIR + PROCESSED_DIR);
EnterBaseData baseData = new EnterBaseData(this);
baseData.run();
Thread baseData = new Thread(new EnterBaseData(this));
baseData.start();
int rowFileSize = rowFilesSize();
for (int i = 0; i < rowFileSize; i++) {
File row = rowFilesPoll();
Expand Down
14 changes: 3 additions & 11 deletions src/main/Lunar.java
Expand Up @@ -4,36 +4,28 @@
import image.PaletteProcess;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import database.BuildDataSets;

public class Lunar {

private final static String MYSQL_IP = "localhost";
private final static String MYSQL_PORT = "3306";
private final static String MYSQL_DB = "lunar";
private final static String MYSQL_USER = "lunar";
private final static String MYSQL_PASSWORD = "lunar";

/**
* @param args
*/
public static void main(String[] args) {
try {
boolean buildDb = true;
boolean buildDb = false;

String path = "E:\\workspaces\\Lunar\\Lunar\\resources\\COLOR_SCALEBAR.TIF";
String path = "resources\\COLOR_SCALEBAR.TIF";
Double totalElevation = 19910d;
Double startElevationValue = -9150d;
if (buildDb) {
PaletteProcess palette = new PaletteProcess();
palette.createPalette(path, totalElevation, startElevationValue);

ImageProcess image = new ImageProcess(palette);
image.generateData("E:\\workspaces\\Lunar\\Lunar\\resources\\WAC_CSHADE_E000N1800_016P.TIF");
image.generateData("resources\\WAC_CSHADE_E000N1800_016P.TIF");
}
BuildDataSets dataSet = new BuildDataSets();
dataSet.buildDataSet(100000);
Expand Down

0 comments on commit daa1468

Please sign in to comment.