Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
5395a834
Commit
5395a834
authored
Jan 23, 2019
by
Evan W. Patton
Committed by
Susan Rati Lane
Jan 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure Polygon Points and HolePoints invalidate map view
Change-Id: I35b143a3dbe3aecdc6c57352468c73e9baf40b72
parent
12188c75
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
4 deletions
+67
-4
appinventor/components/src/com/google/appinventor/components/runtime/Polygon.java
...rc/com/google/appinventor/components/runtime/Polygon.java
+5
-4
appinventor/components/src/com/google/appinventor/components/runtime/util/DummyMapController.java
...pinventor/components/runtime/util/DummyMapController.java
+5
-0
appinventor/components/src/com/google/appinventor/components/runtime/util/MapFactory.java
...oogle/appinventor/components/runtime/util/MapFactory.java
+7
-0
appinventor/components/src/com/google/appinventor/components/runtime/util/NativeOpenStreetMapController.java
...omponents/runtime/util/NativeOpenStreetMapController.java
+8
-0
appinventor/components/tests/com/google/appinventor/components/runtime/MapTestBase.java
...om/google/appinventor/components/runtime/MapTestBase.java
+6
-0
appinventor/components/tests/com/google/appinventor/components/runtime/PolygonTest.java
...om/google/appinventor/components/runtime/PolygonTest.java
+31
-0
appinventor/components/tests/com/google/appinventor/components/runtime/util/DummyMapControllerTest.java
...entor/components/runtime/util/DummyMapControllerTest.java
+5
-0
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/Polygon.java
View file @
5395a834
...
@@ -141,6 +141,7 @@ public class Polygon extends PolygonBase implements MapPolygon {
...
@@ -141,6 +141,7 @@ public class Polygon extends PolygonBase implements MapPolygon {
"Unable to determine the structure of the points argument."
);
"Unable to determine the structure of the points argument."
);
}
}
clearGeometry
();
clearGeometry
();
map
.
getController
().
updateFeaturePosition
(
this
);
}
catch
(
DispatchableError
e
)
{
}
catch
(
DispatchableError
e
)
{
container
.
$form
().
dispatchErrorOccurredEvent
(
this
,
"Points"
,
e
.
getErrorCode
(),
e
.
getArguments
());
container
.
$form
().
dispatchErrorOccurredEvent
(
this
,
"Points"
,
e
.
getErrorCode
(),
e
.
getArguments
());
}
}
...
@@ -209,7 +210,7 @@ public class Polygon extends PolygonBase implements MapPolygon {
...
@@ -209,7 +210,7 @@ public class Polygon extends PolygonBase implements MapPolygon {
"Unable to determine the structure of the points argument."
);
"Unable to determine the structure of the points argument."
);
}
}
clearGeometry
();
clearGeometry
();
map
.
getController
().
updateFeature
Position
(
this
);
map
.
getController
().
updateFeature
Holes
(
this
);
}
catch
(
DispatchableError
e
)
{
}
catch
(
DispatchableError
e
)
{
container
.
$form
().
dispatchErrorOccurredEvent
(
this
,
"HolePoints"
,
container
.
$form
().
dispatchErrorOccurredEvent
(
this
,
"HolePoints"
,
e
.
getErrorCode
(),
e
.
getArguments
());
e
.
getErrorCode
(),
e
.
getArguments
());
...
@@ -222,18 +223,18 @@ public class Polygon extends PolygonBase implements MapPolygon {
...
@@ -222,18 +223,18 @@ public class Polygon extends PolygonBase implements MapPolygon {
public
void
HolePointsFromString
(
String
pointString
)
{
public
void
HolePointsFromString
(
String
pointString
)
{
if
(
TextUtils
.
isEmpty
(
pointString
))
{
if
(
TextUtils
.
isEmpty
(
pointString
))
{
holePoints
=
new
ArrayList
<
List
<
List
<
GeoPoint
>>>();
// create a new list in case the user has saved a reference
holePoints
=
new
ArrayList
<
List
<
List
<
GeoPoint
>>>();
// create a new list in case the user has saved a reference
map
.
getController
().
updateFeature
Position
(
this
);
map
.
getController
().
updateFeature
Holes
(
this
);
return
;
return
;
}
}
try
{
try
{
JSONArray
content
=
new
JSONArray
(
pointString
);
JSONArray
content
=
new
JSONArray
(
pointString
);
if
(
content
.
length
()
==
0
)
{
if
(
content
.
length
()
==
0
)
{
holePoints
=
new
ArrayList
<
List
<
List
<
GeoPoint
>>>();
// create a new list in case the user has saved a reference
holePoints
=
new
ArrayList
<
List
<
List
<
GeoPoint
>>>();
// create a new list in case the user has saved a reference
map
.
getController
().
updateFeature
Position
(
this
);
map
.
getController
().
updateFeature
Holes
(
this
);
return
;
return
;
}
}
holePoints
=
GeometryUtil
.
multiPolygonHolesToList
(
content
);
holePoints
=
GeometryUtil
.
multiPolygonHolesToList
(
content
);
map
.
getController
().
updateFeature
Position
(
this
);
map
.
getController
().
updateFeature
Holes
(
this
);
Log
.
d
(
TAG
,
"Points: "
+
points
);
Log
.
d
(
TAG
,
"Points: "
+
points
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
Log
.
e
(
TAG
,
"Unable to parse point string"
,
e
);
Log
.
e
(
TAG
,
"Unable to parse point string"
,
e
);
...
...
appinventor/components/src/com/google/appinventor/components/runtime/util/DummyMapController.java
View file @
5395a834
...
@@ -229,6 +229,11 @@ class DummyMapController implements MapController {
...
@@ -229,6 +229,11 @@ class DummyMapController implements MapController {
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
@Override
public
void
updateFeatureHoles
(
MapPolygon
polygon
)
{
throw
new
UnsupportedOperationException
();
}
@Override
@Override
public
void
updateFeaturePosition
(
MapCircle
circle
)
{
public
void
updateFeaturePosition
(
MapCircle
circle
)
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
...
...
appinventor/components/src/com/google/appinventor/components/runtime/util/MapFactory.java
View file @
5395a834
...
@@ -441,6 +441,13 @@ public final class MapFactory {
...
@@ -441,6 +441,13 @@ public final class MapFactory {
*/
*/
void
updateFeaturePosition
(
MapPolygon
polygon
);
void
updateFeaturePosition
(
MapPolygon
polygon
);
/**
* Update the holes in a polygon on the map.
*
* @param polygon the polygon that needs its holes updated
*/
void
updateFeatureHoles
(
MapPolygon
polygon
);
/**
/**
* Update the position of a circle on the map.
* Update the position of a circle on the map.
*
*
...
...
appinventor/components/src/com/google/appinventor/components/runtime/util/NativeOpenStreetMapController.java
View file @
5395a834
...
@@ -737,6 +737,14 @@ class NativeOpenStreetMapController implements MapController, MapListener {
...
@@ -737,6 +737,14 @@ class NativeOpenStreetMapController implements MapController, MapListener {
MultiPolygon
polygon
=
(
MultiPolygon
)
featureOverlays
.
get
(
aiPolygon
);
MultiPolygon
polygon
=
(
MultiPolygon
)
featureOverlays
.
get
(
aiPolygon
);
if
(
polygon
!=
null
)
{
if
(
polygon
!=
null
)
{
polygon
.
setMultiPoints
(
aiPolygon
.
getPoints
());
polygon
.
setMultiPoints
(
aiPolygon
.
getPoints
());
view
.
invalidate
();
}
}
@Override
public
void
updateFeatureHoles
(
MapPolygon
aiPolygon
)
{
MultiPolygon
polygon
=
(
MultiPolygon
)
featureOverlays
.
get
(
aiPolygon
);
if
(
polygon
!=
null
)
{
polygon
.
setMultiHoles
(
aiPolygon
.
getHolePoints
());
polygon
.
setMultiHoles
(
aiPolygon
.
getHolePoints
());
view
.
invalidate
();
view
.
invalidate
();
}
}
...
...
appinventor/components/tests/com/google/appinventor/components/runtime/MapTestBase.java
View file @
5395a834
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
package
com.google.appinventor.components.runtime
;
package
com.google.appinventor.components.runtime
;
import
android.view.ViewGroup
;
import
com.google.appinventor.components.common.ComponentConstants
;
import
com.google.appinventor.components.common.ComponentConstants
;
import
com.google.appinventor.components.runtime.shadows.org.osmdroid.tileprovider.modules.ShadowMapTileModuleProviderBase
;
import
com.google.appinventor.components.runtime.shadows.org.osmdroid.tileprovider.modules.ShadowMapTileModuleProviderBase
;
import
com.google.appinventor.components.runtime.shadows.org.osmdroid.views.ShadowMapView
;
import
com.google.appinventor.components.runtime.shadows.org.osmdroid.views.ShadowMapView
;
...
@@ -13,6 +14,7 @@ import com.google.appinventor.components.runtime.util.YailList;
...
@@ -13,6 +14,7 @@ import com.google.appinventor.components.runtime.util.YailList;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.osmdroid.util.GeoPoint
;
import
org.osmdroid.util.GeoPoint
;
import
org.robolectric.annotation.Config
;
import
org.robolectric.annotation.Config
;
import
org.robolectric.internal.Shadow
;
import
static
com
.
google
.
appinventor
.
components
.
runtime
.
util
.
GeometryUtil
.
ONE_DEG_IN_METERS
;
import
static
com
.
google
.
appinventor
.
components
.
runtime
.
util
.
GeometryUtil
.
ONE_DEG_IN_METERS
;
...
@@ -135,6 +137,10 @@ public class MapTestBase extends RobolectricTestBase {
...
@@ -135,6 +137,10 @@ public class MapTestBase extends RobolectricTestBase {
return
map
;
return
map
;
}
}
public
ShadowMapView
getMapShadow
()
{
return
Shadow
.
extract
(((
ViewGroup
)
map
.
getView
()).
getChildAt
(
0
));
}
@Before
@Before
public
void
setUp
()
{
public
void
setUp
()
{
super
.
setUp
();
super
.
setUp
();
...
...
appinventor/components/tests/com/google/appinventor/components/runtime/PolygonTest.java
View file @
5395a834
...
@@ -5,7 +5,9 @@
...
@@ -5,7 +5,9 @@
package
com.google.appinventor.components.runtime
;
package
com.google.appinventor.components.runtime
;
import
android.view.ViewGroup
;
import
com.google.appinventor.components.runtime.shadows.ShadowEventDispatcher
;
import
com.google.appinventor.components.runtime.shadows.ShadowEventDispatcher
;
import
com.google.appinventor.components.runtime.shadows.org.osmdroid.views.ShadowMapView
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
com.google.appinventor.components.runtime.util.GeometryUtil
;
import
com.google.appinventor.components.runtime.util.GeometryUtil
;
import
com.google.appinventor.components.runtime.util.YailList
;
import
com.google.appinventor.components.runtime.util.YailList
;
...
@@ -13,12 +15,17 @@ import org.junit.Before;
...
@@ -13,12 +15,17 @@ import org.junit.Before;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.locationtech.jts.geom.Geometry
;
import
org.locationtech.jts.geom.Geometry
;
import
org.osmdroid.util.GeoPoint
;
import
org.osmdroid.util.GeoPoint
;
import
org.osmdroid.views.MapView
;
import
org.robolectric.Shadows
;
import
org.robolectric.shadow.api.Shadow
;
import
org.robolectric.shadows.ShadowView
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
/**
* Unit tests for the Polygon component.
* Unit tests for the Polygon component.
...
@@ -110,6 +117,14 @@ public class PolygonTest extends MapTestBase {
...
@@ -110,6 +117,14 @@ public class PolygonTest extends MapTestBase {
assertEquals
(
4
,
points
.
size
());
assertEquals
(
4
,
points
.
size
());
}
}
@Test
public
void
testPointsInvalidatesView
()
{
ShadowMapView
view
=
getMapShadow
();
view
.
clearWasInvalidated
();
defaultPolygon
(
polygon
);
assertTrue
(
view
.
wasInvalidated
());
}
@Test
@Test
public
void
testPointsMultipolygon
()
{
public
void
testPointsMultipolygon
()
{
defaultMultipolygon
(
polygon
);
defaultMultipolygon
(
polygon
);
...
@@ -192,6 +207,22 @@ public class PolygonTest extends MapTestBase {
...
@@ -192,6 +207,22 @@ public class PolygonTest extends MapTestBase {
assertEquals
(
3
,
((
YailList
)
holes
.
get
(
1
)).
size
());
// three points in the hole
assertEquals
(
3
,
((
YailList
)
holes
.
get
(
1
)).
size
());
// three points in the hole
}
}
@Test
public
void
testHolePointsInvalidatesView
()
{
defaultPolygon
(
polygon
);
ShadowMapView
view
=
getMapShadow
();
view
.
clearWasInvalidated
();
polygon
.
HolePoints
(
YailList
.
makeList
(
new
Object
[]
{
// First hole
YailList
.
makeList
(
new
Object
[]
{
GeometryUtil
.
asYailList
(
new
GeoPoint
(
0.5
,
0.5
)),
GeometryUtil
.
asYailList
(
new
GeoPoint
(
0.25
,
0.5
)),
GeometryUtil
.
asYailList
(
new
GeoPoint
(
0.5
,
0.25
))
})
}));
assertTrue
(
view
.
wasInvalidated
());
}
@Test
@Test
public
void
testHolePointsMultipolygon
()
{
public
void
testHolePointsMultipolygon
()
{
defaultMultipolygon
(
polygon
);
defaultMultipolygon
(
polygon
);
...
...
appinventor/components/tests/com/google/appinventor/components/runtime/util/DummyMapControllerTest.java
View file @
5395a834
...
@@ -243,6 +243,11 @@ public class DummyMapControllerTest {
...
@@ -243,6 +243,11 @@ public class DummyMapControllerTest {
mapController
.
updateFeaturePosition
((
MapPolygon
)
null
);
mapController
.
updateFeaturePosition
((
MapPolygon
)
null
);
}
}
@Test
(
expected
=
UnsupportedOperationException
.
class
)
public
void
testUpdateFeatureHoles
()
{
mapController
.
updateFeatureDraggable
(
null
);
}
@Test
(
expected
=
UnsupportedOperationException
.
class
)
@Test
(
expected
=
UnsupportedOperationException
.
class
)
public
void
testUpdateFeaturePositionCircle
()
{
public
void
testUpdateFeaturePositionCircle
()
{
mapController
.
updateFeaturePosition
((
MapCircle
)
null
);
mapController
.
updateFeaturePosition
((
MapCircle
)
null
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment