Skip to content

Commit 1a3ccac

Browse files
author
firestack
committed
Remove xcode. fix code. make multiplatform using #if os
1 parent 8c33cd3 commit 1a3ccac

18 files changed

+365
-454
lines changed

NSV.xcworkspace/contents.xcworkspacedata

-13
This file was deleted.

NSV.xcworkspace/xcshareddata/NSV.xcscmblueprint

-37
This file was deleted.
Binary file not shown.

Package.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import PackageDescription
22

33
let package = Package(
44
name: "NSV",
5-
dependencies: [
6-
// .Package(url: "https://github.com/firestack/CPNG.git", majorVersion: 1)
5+
targets: [
6+
Target(
7+
name: "NSV",
8+
dependencies: [.Target(name: "NASA")]
9+
),
10+
Target(
11+
name:"NASA"
12+
)
713
]
814
)

src/NASA/analytics.swift

Whitespace-only changes.

src/NASA/fileDescription.swift

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
2+
import Foundation
3+
4+
public class FileCat: CustomStringConvertible{
5+
var internalData:[String]
6+
7+
init(data:[String]){
8+
internalData = data
9+
}
10+
11+
public var description:String {
12+
get {
13+
return "\n" +
14+
"volumeID: \(volumeID)\n" +
15+
"file specification name: \(fileSpecificationName)\n" +
16+
"product ID: \(productID)\n" +
17+
"map type: \(mapType)\n" +
18+
"map resolution: \(mapResolution)\n" +
19+
"map scale: \(mapScale)\n" +
20+
"lines: \(lines)\n" +
21+
"line samples: \(lineSamples)\n" +
22+
"bits: \(sampleBits)\n" +
23+
"\n"
24+
}
25+
}
26+
27+
public var volumeID:String {
28+
get{
29+
return internalData[0]
30+
}
31+
}
32+
public var fileSpecificationName:String {
33+
get{
34+
return internalData[1]
35+
}
36+
}
37+
public var productID:String {
38+
get{
39+
return internalData[2]
40+
}
41+
}
42+
public var mapType:String {
43+
get{
44+
return internalData[3]
45+
}
46+
}
47+
public var productVersionID:String {
48+
get{
49+
return internalData[4]
50+
}
51+
}
52+
public var productCreationTime:String {
53+
get{
54+
return internalData[5]
55+
}
56+
}
57+
public var maximumLatitude:String {
58+
get{
59+
return internalData[6]
60+
}
61+
}
62+
public var minumumLatitude:String {
63+
get{
64+
return internalData[7]
65+
}
66+
}
67+
public var westernmostLongitude:String {
68+
get{
69+
return internalData[8]
70+
}
71+
}
72+
public var easternmostLongitude:String {
73+
get{
74+
return internalData[9]
75+
}
76+
}
77+
public var mapResolution:String {
78+
get{
79+
return internalData[10]
80+
}
81+
}
82+
public var mapScale:String {
83+
get{
84+
return internalData[11]
85+
}
86+
}
87+
public var lines:String {
88+
get{
89+
return internalData[12]
90+
}
91+
}
92+
public var lineSamples:String {
93+
get{
94+
return internalData[13]
95+
}
96+
}
97+
public var sampleBits:String {
98+
get{
99+
return internalData[14]
100+
}
101+
}
102+
103+
104+
}

src/NASA/glober.swift

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// Glob.swift
3+
//
4+
// Created by Brad Grzesiak on 6/25/15.
5+
// Copyright © 2015 Bendyworks Inc.
6+
// Released under the Apache v2 License.
7+
//
8+
9+
import Foundation
10+
import Glibc
11+
12+
public class Glob: CollectionType {
13+
private var globFlags = GLOB_TILDE | GLOB_BRACE | GLOB_MARK
14+
var paths = [String]()
15+
16+
public var startIndex: Int {
17+
return paths.startIndex
18+
}
19+
20+
public var endIndex: Int {
21+
return paths.endIndex
22+
}
23+
24+
public subscript(i: Int) -> String {
25+
return paths[i]
26+
}
27+
28+
public init(pattern: String) {
29+
var gt = glob_t()
30+
defer{
31+
globfree(&gt)
32+
}
33+
34+
if let cPatt = cPattern(pattern) {
35+
if executeGlob(cPatt, gt: &gt) {
36+
populateFiles(gt)
37+
}
38+
}
39+
}
40+
41+
private func executeGlob(pattern: [CChar], gt: UnsafeMutablePointer<glob_t>) -> Bool {
42+
return 0 == glob(pattern, globFlags, nil, gt)
43+
}
44+
45+
private func cPattern(pattern: String) -> [CChar]? {
46+
return pattern.cStringUsingEncoding(NSUTF8StringEncoding)
47+
}
48+
49+
private func populateFiles(gt: glob_t) {
50+
for i in 0..<gt.gl_pathc{
51+
if let path = String.fromCString(gt.gl_pathv[Int(i)]) {
52+
paths.append(path)
53+
}
54+
}
55+
}
56+
}

src/NASA/indexreader.swift

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//
2+
// indexreader.swift
3+
// NSVX
4+
//
5+
// Created by Firestack on 1/14/16.
6+
// Copyright © 2016 stackfire. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
12+
public class Index{
13+
private let INDEX:NSURL?
14+
private var fin:NSFileHandle?
15+
public var rows = [[String]]()
16+
17+
static public func FindIndex(findFromPath:String) -> NSURL? {
18+
return FileUtil.FindFileFromPath(findFromPath, fileName:"index.tab")
19+
}
20+
21+
public init(pathRoot:String){
22+
INDEX = Index.FindIndex(pathRoot)
23+
openIndex()
24+
preOpen()
25+
26+
}
27+
28+
func openIndex(){
29+
guard let INDEX = INDEX else {
30+
return
31+
}
32+
33+
fin = NSFileHandle(forReadingAtPath: INDEX.path!)
34+
35+
36+
}
37+
38+
func preOpen(){
39+
guard isOpen else{
40+
return
41+
}
42+
43+
let rowString = NSString(data: fin!.readDataToEndOfFile(), encoding: NSASCIIStringEncoding)
44+
for line in rowString!.componentsSeparatedByString("\n"){
45+
guard NSString(string:line).lengthOfBytesUsingEncoding(NSASCIIStringEncoding) > 5 else{
46+
continue
47+
}
48+
49+
#if os(OSX)
50+
//rows.addObject(NSString(string:line).componentsSeparatedByString(","))
51+
rows.append(NSString(string:line).componentsSeparatedByString(","))
52+
#else
53+
//rows.addObject(NSString(string:line).componentsSeparatedByString(",").bridge())
54+
//stringByTrimmingCharactersInSet(NSMutableCharacterSet(charactersInString:"\"")).stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
55+
56+
rows.append(NSString(string:line).componentsSeparatedByString(",").map(stripChars))
57+
#endif
58+
59+
}
60+
}
61+
62+
var isOpen:Bool { get { return ( fin != nil ? true : false ) } }
63+
64+
public func query(searchParams:[SearchQuery]) -> [FileCat]? {
65+
guard isOpen else{
66+
return nil
67+
}
68+
69+
// var q = [String]()
70+
// var qq = [[String]]()
71+
var search = [FileCat]()
72+
73+
for row in rows{
74+
var results = [Bool]()
75+
for searchParam in searchParams{
76+
results.append(searchParam.test(row))
77+
}
78+
79+
if (results.reduce(true) { return $0 && $1 } ) == true {
80+
#if os(OSX)
81+
82+
// q.append((row as! [String]).joinWithSeparator(" , "))
83+
// qq.append(row as! [String])
84+
search.append(FileCat(data:row))
85+
86+
#else
87+
88+
// q.append((row).joinWithSeparator(" , "))
89+
// qq.append(row)
90+
search.append(FileCat(data:row))
91+
92+
#endif
93+
}
94+
95+
96+
}
97+
98+
return search
99+
}
100+
101+
}

src/NASA/labelparser.swift

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Foundation
2+
3+
public class labelInfo {
4+
public init(location:NSURL){
5+
6+
}
7+
}
8+
9+
10+
public class imageProxy{
11+
12+
}

src/NASA/searchDefinition.swift

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Foundation
2+
3+
public class SearchQuery{
4+
public var row:Int
5+
public var match:String
6+
7+
public init(_ row:Int,_ match:String){
8+
self.row = row
9+
self.match = match
10+
}
11+
12+
public func test(rowData:[String]) -> Bool{
13+
return (rowData[row] == match)
14+
}
15+
}

0 commit comments

Comments
 (0)