-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from SEED-platform/upload_btns
1st iteration of property and tax lot upload buttons
- Loading branch information
Showing
12 changed files
with
170 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,5 @@ | |
|
||
textarea { | ||
width: 600px; | ||
height: 400px; | ||
height: 200px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div> | ||
<label for="file">Choose building GeoJSON file</label> | ||
<input | ||
type="file" | ||
id="file" | ||
accept=".geojson" | ||
(change)="handleFileInput($event.target.files)"> | ||
</div> |
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/properties-upload/properties-upload.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PropertiesUploadComponent } from './properties-upload.component'; | ||
|
||
describe('PropertiesUploadComponent', () => { | ||
let component: PropertiesUploadComponent; | ||
let fixture: ComponentFixture<PropertiesUploadComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ PropertiesUploadComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PropertiesUploadComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { PropertyService } from '../core/services/property/property.service'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-properties-upload', | ||
templateUrl: './properties-upload.component.html', | ||
styleUrls: ['./properties-upload.component.scss'] | ||
}) | ||
export class PropertiesUploadComponent implements OnInit { | ||
|
||
constructor(private propertyService: PropertyService) { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
handleFileInput(files: FileList): void { | ||
if (files[0]) { | ||
files[0].text().then(text => { | ||
const geojson = JSON.parse(text); | ||
const crs = geojson.crs ? geojson.crs : { type: 'name', properties: { name: 'EPSG:4326'} }; | ||
|
||
geojson.features.forEach(feature => { | ||
const extra_data = feature.properties; | ||
feature.geometry.crs = crs; | ||
|
||
// extract non-extra_data attributes | ||
const ubid = extra_data.UBID; | ||
delete extra_data.UBID; | ||
|
||
this.propertyService.model.create({ | ||
extra_data: extra_data, | ||
footprint: feature.geometry, | ||
ubid: ubid | ||
}).catch((err) => { | ||
console.error(err); | ||
}); | ||
}); | ||
}) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div> | ||
<label for="file">Choose tax lot GeoJSON file</label> | ||
<input | ||
type="file" | ||
id="file" | ||
accept=".geojson" | ||
(change)="handleFileInput($event.target.files)"> | ||
</div> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TaxlotsUploadComponent } from './taxlots-upload.component'; | ||
|
||
describe('TaxlotsUploadComponent', () => { | ||
let component: TaxlotsUploadComponent; | ||
let fixture: ComponentFixture<TaxlotsUploadComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ TaxlotsUploadComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TaxlotsUploadComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { TaxLotService } from '../core/services/tax-lot/tax-lot.service'; | ||
|
||
@Component({ | ||
selector: 'app-taxlots-upload', | ||
templateUrl: './taxlots-upload.component.html', | ||
styleUrls: ['./taxlots-upload.component.scss'] | ||
}) | ||
export class TaxlotsUploadComponent implements OnInit { | ||
|
||
constructor(private taxlotService: TaxLotService) { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
handleFileInput(files: FileList): void { | ||
if (files[0]) { | ||
files[0].text().then(text => { | ||
const geojson = JSON.parse(text); | ||
const crs = geojson.crs ? geojson.crs : { type: 'name', properties: { name: 'EPSG:4326'} }; | ||
|
||
geojson.features.forEach(feature => { | ||
const extra_data = feature.properties; | ||
feature.geometry.crs = crs; | ||
|
||
// extract non-extra_data attributes | ||
const ubid = extra_data.UBID; | ||
delete extra_data.UBID; | ||
|
||
this.taxlotService.model.create({ | ||
extra_data: extra_data, | ||
footprint: feature.geometry, | ||
ulid: ubid | ||
}).catch((err) => { | ||
console.error(err); | ||
}); | ||
}); | ||
}) | ||
} | ||
} | ||
|
||
} |