File tree Expand file tree Collapse file tree 10 files changed +65
-19
lines changed Expand file tree Collapse file tree 10 files changed +65
-19
lines changed Original file line number Diff line number Diff line change 97
97
<artifactId >slf4j-api</artifactId >
98
98
<version >1.7.30</version >
99
99
</dependency >
100
+ <!-- https://mvnrepository.com/artifact/com.graphhopper.external/jackson-datatype-jts -->
101
+ <dependency >
102
+ <groupId >com.graphhopper.external</groupId >
103
+ <artifactId >jackson-datatype-jts</artifactId >
104
+ <version >0.10-2.5-2</version >
105
+ </dependency >
106
+
100
107
101
108
102
109
</dependencies >
Original file line number Diff line number Diff line change
1
+ package com .brianpondi .gis .controller ;
2
+
3
+ import com .brianpondi .gis .entity .NairobiHealthFacility ;
4
+ import com .brianpondi .gis .service .NairobiHealthFacilityService ;
5
+ import javassist .NotFoundException ;
6
+ import org .springframework .beans .factory .annotation .Autowired ;
7
+ import org .springframework .web .bind .annotation .GetMapping ;
8
+ import org .springframework .web .bind .annotation .PathVariable ;
9
+ import org .springframework .web .bind .annotation .RequestMapping ;
10
+ import org .springframework .web .bind .annotation .RestController ;
11
+
12
+ import java .util .List ;
13
+
14
+ @ RestController
15
+ @ RequestMapping ("/api/nairobihealthfacilities" )
16
+ public class NairobiHealthFacilityController {
17
+
18
+ @ Autowired
19
+ private NairobiHealthFacilityService nairobiHealthFacilityService ;
20
+
21
+ @ GetMapping
22
+ public List <NairobiHealthFacility > findAll () {
23
+ return nairobiHealthFacilityService .findAll ();
24
+ }
25
+
26
+ @ GetMapping (path = "/{id}" )
27
+ public NairobiHealthFacility findById (@ PathVariable ("id" ) int id ) {
28
+ try {
29
+ return nairobiHealthFacilityService .findById (id );
30
+ } catch (NotFoundException e ) {
31
+ e .printStackTrace ();
32
+ }
33
+ return null ;
34
+ }
35
+
36
+ }
Original file line number Diff line number Diff line change 10
10
11
11
12
12
@ RestController
13
- @ RequestMapping ("/api/nairobisubcounty " )
13
+ @ RequestMapping ("/api/nairobisubcounties " )
14
14
public class NairobiSubCountyController {
15
15
16
16
@ Autowired
17
- NairobiSubCountyService nairobiSubCountyService ;
17
+ private NairobiSubCountyService nairobiSubCountyService ;
18
18
19
19
@ GetMapping
20
20
public List <NairobiSubCounty > findAll () {
Original file line number Diff line number Diff line change 1
1
package com .brianpondi .gis .entity ;
2
2
3
- import com .vividsolutions .jts .geom .Geometry ;
4
3
import lombok .Getter ;
5
4
import lombok .Setter ;
6
5
@@ -18,7 +17,7 @@ public class NairobiHealthFacility implements Serializable {
18
17
@ Id
19
18
@ GeneratedValue
20
19
private Integer id ;
21
- private Geometry geom ;
20
+ // private Point geom;
22
21
private String name ;
23
22
private String contact ;
24
23
Original file line number Diff line number Diff line change 1
1
package com .brianpondi .gis .entity ;
2
2
3
- import com .vividsolutions .jts .geom .Geometry ;
4
3
import lombok .Getter ;
5
4
import lombok .Setter ;
6
- import org .springframework .data .annotation .Transient ;
7
5
8
6
import javax .persistence .Entity ;
9
7
import javax .persistence .GeneratedValue ;
@@ -20,8 +18,8 @@ public class NairobiSubCounty implements Serializable {
20
18
@ Id
21
19
@ GeneratedValue
22
20
private Integer id ;
23
- @ Transient
24
- private Geometry geom ;
21
+ // private MultiPolygon geom;
25
22
private String name ;
26
23
24
+
27
25
}
Original file line number Diff line number Diff line change 1
- package com .brianpondi .gis .service ;
1
+ package com .brianpondi .gis .service . Impl ;
2
2
3
3
import com .brianpondi .gis .entity .NairobiHealthFacility ;
4
4
import com .brianpondi .gis .repository .NairobiHealthFacilityRepository ;
5
+ import com .brianpondi .gis .service .NairobiHealthFacilityService ;
5
6
import com .vividsolutions .jts .geom .Geometry ;
6
7
import com .vividsolutions .jts .geom .GeometryFactory ;
7
8
import com .vividsolutions .jts .io .ParseException ;
8
9
import com .vividsolutions .jts .io .WKTReader ;
9
10
import javassist .NotFoundException ;
10
11
import org .springframework .beans .factory .annotation .Autowired ;
12
+ import org .springframework .stereotype .Service ;
11
13
12
14
import java .util .List ;
13
15
16
+ @ Service
14
17
public class NairobiHealthFacilityServiceImp implements NairobiHealthFacilityService {
15
18
19
+ @ Autowired
20
+ private NairobiHealthFacilityRepository nairobiHealthFacilityRepository ;
21
+
16
22
private static GeometryFactory geometryFactory = new GeometryFactory ();
17
23
private static WKTReader wktReader = new WKTReader (geometryFactory );
18
24
19
- @ Autowired
20
- NairobiHealthFacilityRepository nairobiHealthFacilityRepository ;
25
+
21
26
22
27
private static Geometry fromWkt (String wkt ) {
23
28
try {
Original file line number Diff line number Diff line change 1
- package com .brianpondi .gis .service ;
1
+ package com .brianpondi .gis .service . Impl ;
2
2
3
3
import com .brianpondi .gis .entity .NairobiSubCounty ;
4
4
import com .brianpondi .gis .repository .NairobiSubCountyRepository ;
5
+ import com .brianpondi .gis .service .NairobiSubCountyService ;
5
6
import com .vividsolutions .jts .geom .Geometry ;
6
7
import com .vividsolutions .jts .geom .GeometryFactory ;
7
8
import com .vividsolutions .jts .io .ParseException ;
19
20
@ Service
20
21
public class NairobiSubCountyServiceImp implements NairobiSubCountyService {
21
22
23
+ @ Autowired
24
+ NairobiSubCountyRepository nairobiSubCountyRepository ;
25
+
22
26
private static GeometryFactory geometryFactory = new GeometryFactory ();
23
27
private static WKTReader wktReader = new WKTReader (geometryFactory );
24
28
25
- @ Autowired
26
- NairobiSubCountyRepository nairobiSubCountyRepository ;
29
+
27
30
28
31
private static Geometry fromWkt (String wkt ) {
29
32
try {
Original file line number Diff line number Diff line change 2
2
3
3
import com .brianpondi .gis .entity .NairobiHealthFacility ;
4
4
import javassist .NotFoundException ;
5
- import org .springframework .stereotype .Service ;
6
5
7
6
import java .util .List ;
8
7
9
- @ Service
8
+
10
9
public interface NairobiHealthFacilityService {
11
10
List <NairobiHealthFacility > findAll ();
12
11
NairobiHealthFacility findById (int id ) throws NotFoundException ;
Original file line number Diff line number Diff line change 2
2
3
3
import com .brianpondi .gis .entity .NairobiSubCounty ;
4
4
import javassist .NotFoundException ;
5
- import org .springframework .stereotype .Service ;
6
5
7
6
import java .util .List ;
8
7
9
- @ Service
8
+
10
9
public interface NairobiSubCountyService {
11
10
List <NairobiSubCounty > findAll ();
12
11
NairobiSubCounty findById (int id ) throws NotFoundException ;
Original file line number Diff line number Diff line change 3
3
spring.datasource.url =jdbc:postgresql://localhost:5432/nairobigis
4
4
spring.datasource.username =postgres
5
5
spring.datasource.password =123456
6
- spring.jpa.properties.hibernate.dialect =org.hibernate.spatial.dialect.postgis.PostgisDialect
6
+ spring.jpa.database-platform =org.hibernate.spatial.dialect.postgis.PostgisDialect
7
7
spring.jpa.hibernate.ddl-auto =update
8
8
server.port = 8081
You can’t perform that action at this time.
0 commit comments