Using filters to filter a variable value with GeoToolsWhat is the most efficient way to create a shapefile...
What to do with someone that cheated their way through university and a PhD program?
Contradiction proof for inequality of P and NP?
Nails holding drywall
Crossed out red box fitting tightly around image
Why is the underscore command _ useful?
How bug prioritization works in agile projects vs non agile
Why did C use the -> operator instead of reusing the . operator?
Retract an already submitted recommendation letter (written for an undergrad student)
Mistake in years of experience in resume?
As an international instructor, should I openly talk about my accent?
"The cow" OR "a cow" OR "cows" in this context
How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?
Magical attacks and overcoming damage resistance
How long after the last departure shall the airport stay open for an emergency return?
Should the Product Owner dictate what info the UI needs to display?
Co-worker works way more than he should
Apply a different color ramp to subset of categorized symbols in QGIS?
Was Dennis Ritchie being too modest in this quote about C and Pascal?
How to have a sharp product image?
How important is it that $TERM is correct?
How much of a wave function must reside inside event horizon for it to be consumed by the black hole?
Find a stone which is not the lightest one
Help with my training data
Complex numbers z=-3-4i polar form
Using filters to filter a variable value with GeoTools
What is the most efficient way to create a shapefile from resultset using geotoolsUsing Linestring distance in meters with GeoTools?GeoTools FeatureCollection to Filter (make Filter from a FeatureCollection)Creating a raster file from a shapefile using GeoTools with different colours for different featuresStyling features based on a custom rule using GeoToolsHow to calculate whether a point is in a shape using geodetic calculationsgeotools filter CQLException: Encountered “t”Cropping GeoTIFF with GeoTools using integer indexesComparing crses with geotoolsGeotools CQL to OGC filter
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have a Java Swing application which loads a line shapefile and draws a map. I'm using a filter and a rule to filter out the lines in the shapefile where the attribute "traffic" is greater than 500. Each line has a different "traffic" value and this works perfectly ("traffic" means the maximum allowable traffic volume of the road). I can make a separate style for this filtered lines.
Rule rule = sb.createRule(textSymbolizer);
rule.setFilter(sb.getFilterFactory().greater(
sb.getFilterFactory().property("traffic"),
sb.getFilterFactory().literal(500.0)));
FeatureTypeStyle fts = sb.createFeatureTypeStyle("Feature",rule);
Now I want to do the following logic
if("traffic" property value > current_traffic_value){
// style this line uniquely
}
The "current_traffic_value" is a integer value stored in a database for each line. So I want to check each line against a variable value. Can I achieve this using SLD methods? What would be the optimum method to achieve this?
features geotools
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a Java Swing application which loads a line shapefile and draws a map. I'm using a filter and a rule to filter out the lines in the shapefile where the attribute "traffic" is greater than 500. Each line has a different "traffic" value and this works perfectly ("traffic" means the maximum allowable traffic volume of the road). I can make a separate style for this filtered lines.
Rule rule = sb.createRule(textSymbolizer);
rule.setFilter(sb.getFilterFactory().greater(
sb.getFilterFactory().property("traffic"),
sb.getFilterFactory().literal(500.0)));
FeatureTypeStyle fts = sb.createFeatureTypeStyle("Feature",rule);
Now I want to do the following logic
if("traffic" property value > current_traffic_value){
// style this line uniquely
}
The "current_traffic_value" is a integer value stored in a database for each line. So I want to check each line against a variable value. Can I achieve this using SLD methods? What would be the optimum method to achieve this?
features geotools
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
I just found a quick method to accomplish this by using 'EnvFunction'. I first set a unique value 'EnvFunction.setGlobalValue(unique_str, variable_value);'. Then, I'd create a function as ' Function fn = ff.function("env", ff.property(unique_str), ff.literal(0));'. This fn can be easily used in 'rule.setfilter()'. I'm sure there are much better and clean ways to achieve this. The drawback here is that I have to set global value for each line.
– tybandara
Apr 16 '16 at 18:57
add a comment |
I have a Java Swing application which loads a line shapefile and draws a map. I'm using a filter and a rule to filter out the lines in the shapefile where the attribute "traffic" is greater than 500. Each line has a different "traffic" value and this works perfectly ("traffic" means the maximum allowable traffic volume of the road). I can make a separate style for this filtered lines.
Rule rule = sb.createRule(textSymbolizer);
rule.setFilter(sb.getFilterFactory().greater(
sb.getFilterFactory().property("traffic"),
sb.getFilterFactory().literal(500.0)));
FeatureTypeStyle fts = sb.createFeatureTypeStyle("Feature",rule);
Now I want to do the following logic
if("traffic" property value > current_traffic_value){
// style this line uniquely
}
The "current_traffic_value" is a integer value stored in a database for each line. So I want to check each line against a variable value. Can I achieve this using SLD methods? What would be the optimum method to achieve this?
features geotools
I have a Java Swing application which loads a line shapefile and draws a map. I'm using a filter and a rule to filter out the lines in the shapefile where the attribute "traffic" is greater than 500. Each line has a different "traffic" value and this works perfectly ("traffic" means the maximum allowable traffic volume of the road). I can make a separate style for this filtered lines.
Rule rule = sb.createRule(textSymbolizer);
rule.setFilter(sb.getFilterFactory().greater(
sb.getFilterFactory().property("traffic"),
sb.getFilterFactory().literal(500.0)));
FeatureTypeStyle fts = sb.createFeatureTypeStyle("Feature",rule);
Now I want to do the following logic
if("traffic" property value > current_traffic_value){
// style this line uniquely
}
The "current_traffic_value" is a integer value stored in a database for each line. So I want to check each line against a variable value. Can I achieve this using SLD methods? What would be the optimum method to achieve this?
features geotools
features geotools
edited Apr 14 '18 at 19:14
nmtoken
8,15542866
8,15542866
asked Apr 16 '16 at 17:39
tybandaratybandara
1378
1378
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 2 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
I just found a quick method to accomplish this by using 'EnvFunction'. I first set a unique value 'EnvFunction.setGlobalValue(unique_str, variable_value);'. Then, I'd create a function as ' Function fn = ff.function("env", ff.property(unique_str), ff.literal(0));'. This fn can be easily used in 'rule.setfilter()'. I'm sure there are much better and clean ways to achieve this. The drawback here is that I have to set global value for each line.
– tybandara
Apr 16 '16 at 18:57
add a comment |
I just found a quick method to accomplish this by using 'EnvFunction'. I first set a unique value 'EnvFunction.setGlobalValue(unique_str, variable_value);'. Then, I'd create a function as ' Function fn = ff.function("env", ff.property(unique_str), ff.literal(0));'. This fn can be easily used in 'rule.setfilter()'. I'm sure there are much better and clean ways to achieve this. The drawback here is that I have to set global value for each line.
– tybandara
Apr 16 '16 at 18:57
I just found a quick method to accomplish this by using 'EnvFunction'. I first set a unique value 'EnvFunction.setGlobalValue(unique_str, variable_value);'. Then, I'd create a function as ' Function fn = ff.function("env", ff.property(unique_str), ff.literal(0));'. This fn can be easily used in 'rule.setfilter()'. I'm sure there are much better and clean ways to achieve this. The drawback here is that I have to set global value for each line.
– tybandara
Apr 16 '16 at 18:57
I just found a quick method to accomplish this by using 'EnvFunction'. I first set a unique value 'EnvFunction.setGlobalValue(unique_str, variable_value);'. Then, I'd create a function as ' Function fn = ff.function("env", ff.property(unique_str), ff.literal(0));'. This fn can be easily used in 'rule.setfilter()'. I'm sure there are much better and clean ways to achieve this. The drawback here is that I have to set global value for each line.
– tybandara
Apr 16 '16 at 18:57
add a comment |
1 Answer
1
active
oldest
votes
If I understand what you want then it should be a simple filter like:
Rule rule = sb.createRule(textSymbolizer);
rule.setFilter(sb.getFilterFactory().greater(
sb.getFilterFactory().property("traffic"),
sb.getFilterFactory().property("current_trafic")));
FeatureTypeStyle fts = sb.createFeatureTypeStyle("Feature",rule);
I'm sorry if I wasn't clear enough. Actually this is slightly different to what I need. I would need to get the "traffic" property (shapefile attribute) and test it against a value "current_traffic" which is stored in a database. For example, there is a database where the current_traffic for each line is stored. And there is a "traffic" attribute in the shapefile attribute. I want to test these two values. Thanks in advance.
– tybandara
Apr 18 '16 at 8:54
The best plan would be to put all the data in the database and create a view with the join.
– Ian Turton♦
Apr 18 '16 at 8:59
Just for testing purposes I used 'EnvFunction'. For the next update I'd plan to put all data in a database. Then I believe I'd need to check and test both values and draw the line in the unique way manually on a line feature. Is that what you meant by "create a view with the join"?
– tybandara
Apr 18 '16 at 9:05
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f189772%2fusing-filters-to-filter-a-variable-value-with-geotools%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If I understand what you want then it should be a simple filter like:
Rule rule = sb.createRule(textSymbolizer);
rule.setFilter(sb.getFilterFactory().greater(
sb.getFilterFactory().property("traffic"),
sb.getFilterFactory().property("current_trafic")));
FeatureTypeStyle fts = sb.createFeatureTypeStyle("Feature",rule);
I'm sorry if I wasn't clear enough. Actually this is slightly different to what I need. I would need to get the "traffic" property (shapefile attribute) and test it against a value "current_traffic" which is stored in a database. For example, there is a database where the current_traffic for each line is stored. And there is a "traffic" attribute in the shapefile attribute. I want to test these two values. Thanks in advance.
– tybandara
Apr 18 '16 at 8:54
The best plan would be to put all the data in the database and create a view with the join.
– Ian Turton♦
Apr 18 '16 at 8:59
Just for testing purposes I used 'EnvFunction'. For the next update I'd plan to put all data in a database. Then I believe I'd need to check and test both values and draw the line in the unique way manually on a line feature. Is that what you meant by "create a view with the join"?
– tybandara
Apr 18 '16 at 9:05
add a comment |
If I understand what you want then it should be a simple filter like:
Rule rule = sb.createRule(textSymbolizer);
rule.setFilter(sb.getFilterFactory().greater(
sb.getFilterFactory().property("traffic"),
sb.getFilterFactory().property("current_trafic")));
FeatureTypeStyle fts = sb.createFeatureTypeStyle("Feature",rule);
I'm sorry if I wasn't clear enough. Actually this is slightly different to what I need. I would need to get the "traffic" property (shapefile attribute) and test it against a value "current_traffic" which is stored in a database. For example, there is a database where the current_traffic for each line is stored. And there is a "traffic" attribute in the shapefile attribute. I want to test these two values. Thanks in advance.
– tybandara
Apr 18 '16 at 8:54
The best plan would be to put all the data in the database and create a view with the join.
– Ian Turton♦
Apr 18 '16 at 8:59
Just for testing purposes I used 'EnvFunction'. For the next update I'd plan to put all data in a database. Then I believe I'd need to check and test both values and draw the line in the unique way manually on a line feature. Is that what you meant by "create a view with the join"?
– tybandara
Apr 18 '16 at 9:05
add a comment |
If I understand what you want then it should be a simple filter like:
Rule rule = sb.createRule(textSymbolizer);
rule.setFilter(sb.getFilterFactory().greater(
sb.getFilterFactory().property("traffic"),
sb.getFilterFactory().property("current_trafic")));
FeatureTypeStyle fts = sb.createFeatureTypeStyle("Feature",rule);
If I understand what you want then it should be a simple filter like:
Rule rule = sb.createRule(textSymbolizer);
rule.setFilter(sb.getFilterFactory().greater(
sb.getFilterFactory().property("traffic"),
sb.getFilterFactory().property("current_trafic")));
FeatureTypeStyle fts = sb.createFeatureTypeStyle("Feature",rule);
answered Apr 18 '16 at 7:58
Ian Turton♦Ian Turton
50.5k548120
50.5k548120
I'm sorry if I wasn't clear enough. Actually this is slightly different to what I need. I would need to get the "traffic" property (shapefile attribute) and test it against a value "current_traffic" which is stored in a database. For example, there is a database where the current_traffic for each line is stored. And there is a "traffic" attribute in the shapefile attribute. I want to test these two values. Thanks in advance.
– tybandara
Apr 18 '16 at 8:54
The best plan would be to put all the data in the database and create a view with the join.
– Ian Turton♦
Apr 18 '16 at 8:59
Just for testing purposes I used 'EnvFunction'. For the next update I'd plan to put all data in a database. Then I believe I'd need to check and test both values and draw the line in the unique way manually on a line feature. Is that what you meant by "create a view with the join"?
– tybandara
Apr 18 '16 at 9:05
add a comment |
I'm sorry if I wasn't clear enough. Actually this is slightly different to what I need. I would need to get the "traffic" property (shapefile attribute) and test it against a value "current_traffic" which is stored in a database. For example, there is a database where the current_traffic for each line is stored. And there is a "traffic" attribute in the shapefile attribute. I want to test these two values. Thanks in advance.
– tybandara
Apr 18 '16 at 8:54
The best plan would be to put all the data in the database and create a view with the join.
– Ian Turton♦
Apr 18 '16 at 8:59
Just for testing purposes I used 'EnvFunction'. For the next update I'd plan to put all data in a database. Then I believe I'd need to check and test both values and draw the line in the unique way manually on a line feature. Is that what you meant by "create a view with the join"?
– tybandara
Apr 18 '16 at 9:05
I'm sorry if I wasn't clear enough. Actually this is slightly different to what I need. I would need to get the "traffic" property (shapefile attribute) and test it against a value "current_traffic" which is stored in a database. For example, there is a database where the current_traffic for each line is stored. And there is a "traffic" attribute in the shapefile attribute. I want to test these two values. Thanks in advance.
– tybandara
Apr 18 '16 at 8:54
I'm sorry if I wasn't clear enough. Actually this is slightly different to what I need. I would need to get the "traffic" property (shapefile attribute) and test it against a value "current_traffic" which is stored in a database. For example, there is a database where the current_traffic for each line is stored. And there is a "traffic" attribute in the shapefile attribute. I want to test these two values. Thanks in advance.
– tybandara
Apr 18 '16 at 8:54
The best plan would be to put all the data in the database and create a view with the join.
– Ian Turton♦
Apr 18 '16 at 8:59
The best plan would be to put all the data in the database and create a view with the join.
– Ian Turton♦
Apr 18 '16 at 8:59
Just for testing purposes I used 'EnvFunction'. For the next update I'd plan to put all data in a database. Then I believe I'd need to check and test both values and draw the line in the unique way manually on a line feature. Is that what you meant by "create a view with the join"?
– tybandara
Apr 18 '16 at 9:05
Just for testing purposes I used 'EnvFunction'. For the next update I'd plan to put all data in a database. Then I believe I'd need to check and test both values and draw the line in the unique way manually on a line feature. Is that what you meant by "create a view with the join"?
– tybandara
Apr 18 '16 at 9:05
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f189772%2fusing-filters-to-filter-a-variable-value-with-geotools%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I just found a quick method to accomplish this by using 'EnvFunction'. I first set a unique value 'EnvFunction.setGlobalValue(unique_str, variable_value);'. Then, I'd create a function as ' Function fn = ff.function("env", ff.property(unique_str), ff.literal(0));'. This fn can be easily used in 'rule.setfilter()'. I'm sure there are much better and clean ways to achieve this. The drawback here is that I have to set global value for each line.
– tybandara
Apr 16 '16 at 18:57